WorkspaceLearning path
Level 1 · Foundations
BUILD YOUR INTUITION

Binary Search

A comparison proves that one half of the remaining candidates cannot contain the answer.

THE MENTAL MODEL

When should this come to mind?

A comparison proves that one half of the remaining candidates cannot contain the answer.

Sorted inputMonotonic predicateFirst feasible value

What makes it work

Choose inclusive or half-open bounds and keep that convention throughout.

When to choose something else

Without sorted order or monotonicity, eliminating half the candidates is not justified.

See the pattern in action

Change the input. Follow the state. Make it yours.