Sedgewick & Wayne · §4.2 Sorting and Searching

Twenty Questions: Converting to Binary

Every yes/no comparison cuts the range of possible numbers in half. Ask 7 well-chosen questions and you've narrowed 128 possibilities down to exactly one — that's binary search, and the trail of answers is the binary representation.
77
binary representation, revealed one bit at a time
your number
Question log
Press “Ask” to pose the first question.

This mirrors the book's "twenty questions" analogy: instead of guessing, each threshold is chosen to always split the remaining range exactly in half — the same idea whether you're converting a number to binary, weighing an object against a balance, or inverting a monotonic function with binary search.