| |
| | ongoing · On the Goodness of Binary Search |
 | | On the other hand, binary search is so simple and robust that you can code up five subtly different binary searches for different places in your code, all using optimized direct references into your internal structures, and not suffer any software engineering angst. |
 | | All that said, the core idea of binary search is mind-bogglingly simple; you have a sorted array, you look at the middle element which tells you what you're looking for is in the top or bottom half, then you take that half, rinse and repeat until done. |
 | | Suppose, for example, you want to search for a range in that array; take two input numbers and find the index of the entry that is smaller than the lesser of them, and of the entry that is larger than the greater. |
| www.tbray.org /ongoing/When/200x/2003/03/22/Binary (2065 words) |
|