← The collection

Binary Search.

Find a hidden integer by splitting an ordered range rather than scanning every candidate.

Interactive experimentintuitiveField note ·
INTERACTIVE EXPERIMENT / P16

Binary Search

Find a hidden integer by splitting an ordered range rather than scanning every candidate.

PLAY & EXPLAIN

Find a hidden integer from 1 to 32. Each guess reveals whether it is lower or higher. Try dividing the remaining range rather than testing every number.

Guesses
0
Remaining range
1–32
Midpoint worst-case bound
6 guesses

The bound includes identifying one of 32 integers with an equality check. Binary search needs ordered candidates and reliable comparisons; it does not apply to arbitrary unordered data without preparation.

Comparisons are reliable and the candidate order is known. Preprocessing an unordered collection has a cost that this guessing game omits.

THE SHORT VERSION

Binary Search, explained.

Binary search repeatedly compares a target with a midpoint to discard part of an ordered search space.

01 / THE MECHANISM

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.

02 / FOLLOW IT THROUGH

A worked example

Find one of thirty-two ordered targets

  1. Use the midpoint button for the first guess and inspect the surviving interval.

  2. Continue taking midpoints, discarding the side excluded by each lower-or-higher result.

  3. 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.

03 / BEYOND THE EXPERIMENT

Where this idea is useful

A practical use

Recognise when ordering information can turn a long lookup into a logarithmic search.

CHECK YOUR INTUITION

A common misconception

THE TEMPTING CONCLUSION

“Binary search finds arbitrary unordered records without preparation.”

THE MORE USEFUL DISTINCTION

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.
ONE MORE QUESTION

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.

TAKE THE IDEA WITH YOU

Which comparison lets you safely discard an entire group of candidates?

Associated thinkers

Associated withDonald Knuth ↗

Associations marked provisional are awaiting source review.

Further reading

Explore the original research or the teaching reference behind this experiment.