Tutorpip← About this lessonOpen the sheet →Download PDF
Ages 8+ · Coding · Decisions
Choosing with questions
01234566Start3After wings2After water1After meowanimals left
Each good question leaves fewer animals.
The big ideaA good yes or no question cuts the choices down, and the answers make a tree.

How it works

A good yes or no question cuts the choices into two piles.

A question tree is a map of yes or no questions. Each answer picks one branch.

A good question splits the choices about in half, so only a few questions are needed.

Asking about one animal at a time is slow, because each question checks only one card.

1Does it have wings? no2Does it live in water? no3Does it say meow? no4It is the dog!
The dog round, as a list of questions.

Example 1: One by one

  1. Six cards lie on the table: an owl, a parrot, a duck, a dog, a cat and a goldfish.
  2. Bo asks about one card at a time, and each answer is no.
  3. After 5 questions he knows it is the goldfish.

Example 2: Two piles

  1. Ravi says to ask Does it have wings?
  2. Yes keeps the owl, the parrot and the duck, which is 3 cards.
  3. No keeps the dog, the cat and the goldfish, which is 3 cards. Half the cards are gone at once.

Example 3: The dog round

  1. The secret is the dog, and the first answer is no to wings, so 3 cards are left.
  2. Does it live in water? No leaves the dog and the cat, which is 2 cards.
  3. Does it say meow? No leaves only the dog. That is 3 questions, not 5.
01234566Start3After wings2After water1After meowanimals left
Animals left after each question.

Example 4: Finding the cat

  1. The secret is the cat.
  2. No to wings, no to water, and yes to does it say meow.
  3. Those three answers leave only the cat.

Words to know

question tree
A map of yes or no questions.
branch
The path an answer picks.
split
To cut the choices into two piles.

Watch out

Try it

  1. Does Does it have wings? keep the dog, or the owl, in the yes pile?
  2. Is Is it the duck? a question that splits the cards?
  3. Six cards. A question cuts them in half. How many are in each pile?
  4. How many answers can a yes or no question have?
  5. Which is faster: asking about one animal at a time, or asking a splitting question?
Answers: 1. The owl · 2. No · 3. 3 · 4. 2 · 5. A splitting question
Try at homePlay guess the animal, or guess an object, with a grown-up. Ask only yes or no questions and try to find the answer in as few questions as you can. Try asking questions that cut the choices in half.
For grown-upsPlay guess the animal, or guess an object, together. Ask only yes or no questions and try to find the answer in as few questions as you can, by asking ones that cut the choices in half.
Open these notes on screenScan the code, or go to tutorpip.com.