Hacker News new | ask | show | jobs
by nickcw 1564 days ago
I agree - the best binary search algorithm is the one someone else wrote, preferably in the standard library of the language you are using.

I've written binary search algorithms maybe a half a dozen times, and every time I get tripped up by some boundary condition or other and what is only a few lines of code takes a really long time to get exactly right for all the corner cases.

1 comments

You'd be surprised how often standard libraries can be broken. The integer overflow bug for binary search has been found in many of them.