Binary Search, explained.
Binary search repeatedly compares a target with a midpoint to discard part of an ordered search space.
Why it happens
A hidden integer lies from one to thirty-two. Each correct lower/higher response narrows the candidate interval; the midpoint strategy needs at most six equality-tested guesses.
Binary search repeatedly compares a target with a midpoint to discard part of an ordered search space.
Read the result
The remaining range uses reliable ordered comparisons. A successful guess ends the game instead of pretending another split is required.
A worked example
Find one of thirty-two ordered targets
Use the midpoint button for the first guess and inspect the surviving interval.
Continue taking midpoints, discarding the side excluded by each lower-or-higher result.
Count the equality-tested guesses and compare with the six-guess worst-case bound.
OPTIONAL DEEPER DETAILGo deeper: inside the model
Inside this model
A hidden integer lies from one to thirty-two. Each correct lower/higher response narrows the candidate interval; the midpoint strategy needs at most six equality-tested guesses.
Where this idea is useful
A practical use
Recognise when ordering information can turn a long lookup into a logarithmic search.
A common misconception
“Binary search finds arbitrary unordered records without preparation.”
The method requires order or a monotonic comparison that safely discards a region. Establishing that structure can itself cost work.
What this explanation leaves out
- Comparisons are reliable and the candidate order is known. Preprocessing an unordered collection has a cost that this guessing game omits.
Why can thirty-two candidates need six guesses?
The game counts the final equality test as a guess; identifying an endpoint can require that extra comparison after narrowing.
Which comparison lets you safely discard an entire group of candidates?
Associated thinkers
Associations marked provisional are awaiting source review.
Further reading
Explore the original research or the teaching reference behind this experiment.