Primitives
ComputingPlate 36

Binary search

Binary search

In a sorted row, one comparison can rule out half the remaining values.

Inside the plate
Check the middle
01 / 03
Binary search
5
01

Check the middle

Start with the center card. If it holds your number, the search is over.

02

Choose a half

A smaller number must be on the left. A larger one must be on the right. Try the middle of that half.

03

Narrow it again

Each dot records a comparison. With these seven cards, even the longest search takes three.

Binary search

Turn the page