Skip to content
STEM Little Explorers
HR
Paper-cut illustration of a child arranging number cards from 50 through 90 in a narrowing guessing path, with 90 circled

Guess My Number in 7 Questions: Binary Search for Kids

Iva Leder
Iva Leder
13 min read

Free summer e-book

Summer of curiosity

Download freeNo sign-up

Here is a trick you can do in a car, in a queue, or at a birthday party.

Ask someone to think of a number from 1 to 100 and keep it secret. Tell them you will find it in seven questions, and that all they have to answer is "higher", "lower", or "that's it".

Then ask: is it 50?

Higher. Ask 75. Higher. Ask 88. Higher. Ask 94. Lower. Ask 91. Lower. Ask 89. Higher. There is only one number left that fits every answer, so ask your seventh question: is it 90? That's it.

It works every time, for every number, and it never needs an eighth question. It also happens to be one of the most useful ideas in computer science, and a child who plays this game for ten minutes can figure it out.

  • Age:6+
  • Time:15 min
  • Difficulty:Easy
  • Mess level:None
  • Supervision:No

🎮 Play as you read

The game below plays both sides: let it find your number, or try to find its number yourself and see whether you can do it in seven questions or fewer. Prefer a full page? Open guess my number in 7 questions.

The rule: always aim for the middle

The whole method is one sentence: guess the middle of whatever is still possible.

At the start, anything from 1 to 100 is possible, so the middle is 50. If the answer is "higher", you can eliminate everything from 1 to 50, and you are left with 51 to 100. The middle of that is 75. If the answer is "lower", 76 to 100 disappear, and you are down to 51 to 74.

Every wrong guess leaves at most half the previous range. If the range contains an odd number of possibilities, the guess itself sits in the middle, so the two sides are exactly equal. If it contains an even number, one side can contain one more number than the other. Either way, "higher" and "lower" are almost equally useful, and "that's it" ends the game.

Watch the pile shrink:

Wrong guesses so farAt most this many numbers remain
0100
150
225
312
46
53
61

After six wrong guesses, at most one number remains. Question seven names and confirms it. There is no room left for an eighth question.

The example opening written as a picture: every answer keeps one smaller range and discards everything else. After six wrong guesses, only 90 remains; question seven confirms it.

Think of a number and keep it secret. Answer honestly and watch how few questions it takes.

Numbers from 1 to

Is your number

50?

1100

100 numbers still possible

Questions used: 0 of 7

Largest range that can remain after each wrong guess:

100502512631

Play it the other way round

Once your child has watched you do it, swap. You think of the number and let them find it, and resist the urge to coach.

What almost every child does first is guess 1, then 2, then 3. It's good to let them do it for a while, because it's quickly obvious that this approach is inefficient. Counting up from 1 needs up to 100 guesses. Then ask them to try starting in the middle, and let them feel the difference.

The moment to watch for is when they stop guessing "a number" and start guessing "the middle of what is left". Those are two completely different games, and the second one is an algorithm: a recipe that works for any number without needing luck.

For younger learners

For preschool, kindergarten and early elementary, start with numbers from 1 to 10, then move to 1 to 20. Draw a number line or lay numbered cards face up, and let the child cover the eliminated numbers with counters or strips of paper or physically move them out of the way. The visual and tactile experience makes the halving trick more concrete than just saying "higher" or "lower".

Leave powers of two, software terms, and even the name "binary search" for later. For now, ask: Which number is in the middle? Which numbers can we cover? The central idea is enough: choosing the middle lets us rule out lots of numbers at once.

The full 1-to-100 game is an especially good fit for elementary school. Children around 7 to 11 can work with the middle of a range, higher and lower, elimination, efficient versus inefficient strategies, and ordered versus shuffled numbers. Older learners (11+) can go further into powers of two, algorithms as repeatable instructions, and why 1,000 still needs only ten questions.

Seven questions are enough for 1 to 100. How many questions do you need for 1 to 1000?

Make your prediction, then tap an answer to check!

Advertisement

Why doubling is so powerful

Those capacities sit one below the powers of two: 1, 3, 7, 15, 31, 63, 127, 255… Add one question and the pile you can search roughly doubles. More precisely, if the final guess must be confirmed, q questions can cover 2^q − 1 numbers.

Turn it around and you get the rule: keep doubling until the capacity reaches your range. A hundred needs 7 questions because 2⁷ − 1 = 127. A thousand needs 10 because 2¹⁰ − 1 = 1023. A million needs 20. A billion needs only 30.

Your child has met this doubling before if they have played with the Tower of Hanoi, where each extra disk doubles the previous minimum and adds one move, or if they have written their name in binary, where each extra bit doubles how many different symbols can be encoded. The same growth pattern drives all three.

Where the halving trick shows in everyday life

When you look up a word in a paper dictionary, you do not start at A. You open it somewhere near the middle, see whether your word comes before or after, and pick a side. It is not a perfectly measured binary search, but it uses the same middle-and-discard idea. Programmers use the exact method with tools such as git bisect: test a change halfway between a version known to work and one known to be broken, then discard half the history.

The catch that makes it computer science

There is one condition, and you probably know it intuitively. Ask your child:

Could you play this game if the numbers were shuffled up, so that "higher" and "lower" meant nothing?

You could not. Halving only works because the numbers are in order. The answer "higher" is only useful if it lets you rule out everything below, and that needs the pile to be sorted.

This is one reason computers keep some data in order. A sorted list of 2,000 contacts can be searched in at most 11 midpoint comparisons. Unsorted, a simple search might have to inspect all 2,000. Sorting or indexing data takes work up front, but it can make repeated searches much faster.

🔬 Turn it into a real experiment

Test the condition instead of taking our word for it. Write the numbers 1 to 20 on cards, shuffle them, and lay them face down in a row. Now try to find the card with 13 on it. After each flip, compare the revealed number with 13, but because the cards are shuffled, "higher" or "lower" tells you nothing about where to look next. Count the flips: on average you will turn over about half the cards, and sometimes all of them. Then lay the same cards out in order, face down, and play again. Five flips at most, every time. Same cards, same comparison, and the only thing that changed was the order.

For older explorers: turn it into code

Middle-school learners can write the strategy in Scratch or pseudocode. Keep two variables, lowest and highest, calculate the middle, and update one boundary after every answer:

lowest = 1
highest = 100

while lowest <= highest:
  middle = floor((lowest + highest) / 2)
  ask whether middle is correct, too low, or too high
  if correct: stop
  if too low: lowest = middle + 1
  if too high: highest = middle - 1

For an optional mathematics extra, the exact number of questions in this article's confirmed-final-guess version is ⌈log₂(n + 1)⌉. You may also see ⌈log₂ n⌉ used for the number of halving decisions needed to narrow a range to one candidate; the extra confirmation question is why the formulas differ at powers of two.

Advertisement

Playing it away from a screen

A number line on paper. Draw 1 to 100 as a line and cross out the half that each answer eliminates. Seeing the surviving stretch get physically shorter does more for a young child than any amount of explaining.

The dictionary race. You look up a word by starting at A and turning one page at a time. Your child looks up a different word by opening the middle and halving. Race. It is not close.

Guess the age, guess the weight. The same trick finds anything with an order to it: how many sweets are in the jar, how many pages in the book, what number I am thinking of between 1 and 1000.

Twenty questions, properly. The classic game is similar to binary search, but on ideas rather than numbers. A good question is one that splits the possibilities roughly in half. "Is it an animal?" is a strong question. "Is it a hamster?" is a weak one. That is a genuinely useful thing for a child to notice about questions.

Key takeaways

  • To find a secret number from 1 to 100, always guess the middle of what is still possible. It takes at most 7 questions.
  • Every wrong guess leaves at most half the previous range; an exact guess ends the game.
  • Each extra question roughly doubles the size of the pile you can search: 7 confirmed questions cover 127 numbers, 10 cover 1,023, and 20 cover 1,048,575.
  • This is called binary search, and it only works when the things you are searching are in order. That is why computers sort things.
  • The same halving finds a word in a dictionary, a page in a book, and a bug in a program.
  • Guessing 1, 2, 3, 4 in turn is the honest comparison: up to 100 guesses instead of 7.

Guessing games and binary search - Frequently Asked Questions

How can you always guess a number from 1 to 100 in 7 tries?

Always guess the middle of the range that is still possible. Start at 50. If the answer is "higher", the range becomes 51 to 100 and you guess 75; if "lower", it becomes 1 to 49 and you guess 25. In the worst case the possible range shrinks from 100 to 50, 25, 12, 6, 3 and 1. The seventh question confirms that final number.

What is binary search in simple terms?

It is a way of finding something in an ordered list by repeatedly cutting the list in half. Look at the middle item, decide whether what you want is before or after it, throw the other half away, and repeat. "Binary" means two, because every step splits things into two parts and discards one.

How many guesses do you need for 1 to 1000?

Ten. With a confirmed final guess, the maximum range grows 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023. Ten questions therefore cover every number from 1 to 1000. For a million you need only 20, and for a billion 30.

Why does binary search need a sorted list?

Because the answers only help if they let you rule out a whole half at once. "Higher" tells you nothing about a shuffled pile: the number you want could still be anywhere. In an ordered list, "higher" eliminates everything below the item you checked. No order, no halving, and you are back to looking at things one by one.

Is this the same as the game 20 questions?

It is the same idea applied to ideas rather than numbers. Twenty yes-or-no questions can separate more than a million possibilities, as long as each question splits what is left roughly in half. That is why "is it alive?" is a much better opening question than "is it a goldfish?".

What age can children learn binary search?

The guessing game itself works from about 5 or 6, played out loud with an adult doing the halving. Around 8 or 9 most children can find the middle themselves and stick to the strategy. The reasoning about why doubling makes 7 enough for 100, and the fact that the list must be sorted is all about exponentials and logarithms, so it's a good fit for middle schoolers (11+).

How is binary search used in real programs?

Binary search appears wherever programs keep comparable data in order. A program can search a sorted array directly; database tree indexes use the same discard-large-regions principle; and version-control tools such as git bisect find the change that broke a program by repeatedly testing the middle of a known good-to-bad history. Other jobs may use different structures, such as hash tables or prefix trees, so not every computer search is binary search.

If your child liked seeing a party trick turn into real computer science, these are the neighbours of this article:

Till next time, enjoy the game and keep exploring!

Topics
Share this article:
Iva Leder
Iva Leder

Psychologist

The founder of STEM Little Explorers and a lifelong lover of learning, she believes that education has the power to change lives. Always searching for more creative and effective ways to teach, she sees unlimited potential in every child. Her mission is simple: to help unlock that potential by finding the approach that works best for each unique learner.

More articles by this author →

Enjoyed this article?

Subscribe to get new posts straight to your inbox.

No spam, unsubscribe anytime.

Related Posts