Binary search
easy 16 minBinary search finds a value, a boundary or an insertion point in sorted data by checking the middle and discarding the half that cannot hold the answer.
Where it shows up
The same pattern appears across everyday software.
Database indexes
B-tree pages and sorted string tables (SSTables) store keys in order. Engines binary search inside each page to choose the child pointer or find the row, so a lookup touches a handful of pages instead of the whole table.
Finding the commit that broke the build
git bisect binary-searches your history: mark one good and one bad commit, and it checks out the middle each time. About 10 tests find the culprit among 1,000 commits.
Standard library search
Python's bisect module, C++ std::lower_bound and std::upper_bound, and Java's Arrays.binarySearch are all binary search on sorted sequences, used for insertion points, ranges and counts.
Dictionaries and phone books
Word lookups in a sorted dictionary or contact list work by opening near the middle and discarding the half that cannot contain the word, which is binary search done by hand.
IP routing and lookup tables
Routers and firewalls keep sorted ranges of addresses and binary search them to find which range an address falls in, instead of scanning every rule.
Tuning by halving
Finding the largest batch size that fits in GPU memory, or the lowest bitrate that still passes a quality check, is binary search on the answer: try the middle, keep the half that still works.