Binary Search

Binary search · Discard half using a sorted invariant · Easy · about 16 min

Why it matters

Binary search is less about finding a number and more about maintaining a true search range.

How it connects

Linear scans check one possibility at a time; sorted order lets you eliminate many at once.

Try first

After comparing the middle value, which half can no longer contain the answer?

Interview cue

The sorted invariant lets me halve the search space each step: O(log n).