Binary Search on the Answer
Turn an optimization problem into a monotone feasibility predicate and search the numeric answer range.
Core idea
Replace direct optimization with a yes-or-no predicate such as whether capacity x is sufficient. If feasibility changes only once, binary search finds that boundary.
Read the visualization
The numeric answer interval shrinks around each midpoint. The feasibility panel explains the check, and colors distinguish impossible from feasible values.
Define the numeric answer interval and its monotone feasibility predicate.
Complexity and tradeoffs
Time: O(check × log range). Space: O(1) beyond the check. Correctness depends on a monotone predicate and a precisely defined first-true or last-true boundary.
Where it fits
Binary search on the answer solves capacity planning, partition limits, minimum speed, maximum spacing, and many problems whose candidate range is ordered but not explicitly listed.