If you looking for feedback on your proposed algorithm (rather than code)...
I would probably take a similar approach, assuming that the array is large enough that a binary search is expected to be more efficient than creating an index of the first n characters of each string.
Keep in mind, though, that when you do the binary search for $beg you are getting information not only about the position of $beg, but also about $end. Each time you compare a string from the array to $beg you could also determine the relative location of $end to that string. Then, once you nail down the position of $beg you could potentially start searching for the exact position of $end using a much smaller search space. (The actual benefit achieved will depend on the positions of $beg and $end within the array.)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|