19 worked problems

Binary Search

Halve the search space every step. Answers become permanently feasible after a boundary, or the sorted search space can discard half at once.

Recognition signal

When should you think of Binary Search?

Answers become permanently feasible after a boundary, or the sorted search space can discard half at once.

Core invariant

What must stay true?

The answer remains inside the maintained interval after every comparison.

Practice in a deliberate order

What to learn in this cluster

  1. 01Search a sorted array
  2. 02Boundary and rotated-array search
  3. 03Binary search on the answer

All Binary Search problems

19 of 19 walkthroughs
Continue the cluster

Related patterns and study guides