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.
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?