How binary search finds 42
The numbers are sorted, so one look at the middle tells you which half the answer can’t be in. Throw that half away and look at the middle of what’s left.
Why it’s fast
Each look halves what’s left: 15 numbers, then 7, then 3, then 1. Reading left to right, 42 is the tenth number you’d check.
The halving is what scales. A million sorted numbers take at most 20 looks.
In code, keep two indices, low and high, look at mid = ⌊(low + high) / 2⌋, and move one of them past mid until the number turns up or they cross.