AlgoPlus//structures / binary-search-answer
Read the theory

Binary Search on the Answer · Integer √

Halve the candidate range using a monotonic feasibility test.

Target
50
⌊√⌋
0
Legend
lo / hi
feasible
too big
AI Tutor Workspace
In a nutshell
Instead of searching for a value inside a list, this binary-searches the answer itself across its possible range. It works whenever a yes/no test flips just once — true for everything up to some boundary, then false after (or vice versa). Testing the middle of the range tells you which half the boundary is in, so each test throws away half the candidates. Finding the integer square root of a number is a classic example: 'is mid² ≤ target?' is true for small mid and false once mid gets too big.
Ready
Press play to begin the cinematic walkthrough.
When a yes/no test is monotonic (false… then true…), binary-search the *answer* itself: halve the candidate range by testing the middle.
Key terms
Go deeper in the lesson
Read the full theory, intuition & complexity for Binary Search on the Answer · Integer √.