Alex Rivera | Logout

What are the pitfalls in implementing binary search?

Asked 2009-02-02T18:35:44.323
73

Binary search is harder to implement than it looks. "Although the basic idea of binary search is comparatively straightforward, the details can be surprisingly tricky…" — Donald Knuth.

Which bugs are most likely to be introduced into a new binary search implementation?

Edit
Report

1 Answer

1

Failing to consider that when calculating the midpoint between two indices summing the high and low values may result in integer overflow.

Reference

answered 2009-02-02T18:41:23.547

Your Answer