Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Modified Binary Search

by jethro (Monsignor)
on Jan 13, 2010 at 18:01 UTC ( #817241=note: print w/replies, xml ) Need Help??


in reply to Modified Binary Search

I think you just have to drop the stop condition, i.e. in the classical case the algorithm stops when the search string is found. Here you have to look on until the upper and lower ends of the search interval are reduced to neighboring elements (i.e. no further halving step is possible). The upper element is the the one you want in the case of $beg, the lower element the one in case of $end.

Small special case: If the search interval contracts to elements 0 and 1, $beg might start at 0. Other way round for $end

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://817241]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2021-06-17 17:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (84 votes). Check out past polls.

    Notices?