✂️ Cut it in half: binary search
Why: Binary search: find anything in a sorted list by halving — a billion items, ~30 steps.
Unlocks: Sorting — how lists earn the right to be searched this fast.
You've already PLAYED this algorithm: the mind reader guessed your 1-100 number in 7 questions by asking "bigger than 50?" and throwing away half the world with every answer. That strategy has a name — binary search — and one demand: the list must be sorted. A phone book works because names are alphabetical; open the middle, and you instantly know which half to keep.
Why 7? Because 100 halves into 50 → 25 → 13 → 7 → 4 → 2 → 1. Each question kills half the suspects. Now enjoy the absurdity of how slowly that grows:
| List size | Linear search | Binary search |
|---|---|---|
| 100 | 100 checks | 7 checks |
| 1,000,000 | 1,000,000 checks | 20 checks |
| 1,000,000,000 | 1,000,000,000 checks | 30 checks |
| Every human on Earth | 8,000,000,000 checks | 33 checks |
A sorted list doubles from one billion to two billion entries. Binary search's worst case goes from 30 to…
Why can't you binary-search an unsorted list?
🔍 Go deeper: replay this exact recipe in slow motion in the mind reader project, or trace lists under the hood in PyDebug: Lists.