What's the fastest way to search?

You're hunting for one name in a giant sorted list β€” a class roster, a phone full of contacts. Do you really have to check every single one?

1Two things to know first

The list is sorted, and you can split it

You need two small ideas. Watch each one happen:

The list is in order

The cards go smallest to biggest, left to right. So if a card is too big, everything to its right is too big too.

Peek the middle, toss half

Peek at the middle card. If your number is bigger, you can throw away the whole left half β€” for good.

2Two ways to hunt

The creeper vs the halver

🐌 The creeper

Starts at the front and checks every single card in order until it bumps into the right one. Simple, but slow.

πŸ‡ The halver

Always jumps to the middle and throws away half the list each peek. Keep this in mind…

3Feel the slow way

Send the creeper down the row

Here's the creeper. Drag it along and count how many cards it has to peek at, one by one, before it lands on the card you want.

Creeper peeked at: 0 cards
STARTCARD #88

The creeper checks card 1, then 2, then 3… all the way to your card. No skipping. Now β€” is there a smarter way?

4Now race them

Creeper vs halver, for card #88 🏁

Both searchers start now, hunting for card #88 in a sorted row of 100. The creeper goes one by one. The halver jumps to the middle and tosses half the cards each peek.

Guess before they race

You're looking for card #88 in a sorted row of 100 cards. If you're smart about it, about how many cards do you HAVE to peek at?