ChoralSoft Learn
Binary search, step by step
Why finding an item among a thousand sorted items takes about ten guesses.
Watch binary search halve the problem
The list is sorted, so each guess at the middle lets us throw away half of what is left. Pick a target, then step through or press play.
37111216202125293034383943474852565761656670747579838488929397
Press Step to make the first guess.
Binary search steps: 0 Worst case for 32 items: 6 Linear search would take up to: 32
Doubling the list adds only one extra step, which is what O(log n) means.
Go deeper
- Article: Binary search explained visually
- Article: Big-O in plain language
- Interactive: Big-O growth chart
- Book: Algorithms Made Simple
More explainers: Learn hub · Printable cheat sheets · Learning paths
