Tutorpip← About this lessonOpen the sheet →Download PDF
Ages 8+ · Coding · Patterns and algorithms
Searching a list
Open the nextboxIs this theone?Yes: stoplookingNo: go on tothe next box
Searching a list in order.
The big ideaSearch a list one item at a time, in order. Stop when you find it.

How it works

To search a list, check one item at a time, in order.

Stop as soon as you find what you want. There is no need to open the rest.

If you reach the end and it is not there, it is not in the list, because every box was checked once.

In order, no box is opened twice and none is missed.

🍃box 1: leaf🌙box 2: moon🐚box 3: shell🪁box 4: kite⭐box 5: star
Jonah's boxes 1 to 5.

Example 1: Find it, then stop

  1. Jonah wants his star sticker. Bo opens box 1: a leaf. Box 2: a moon. Box 3: a shell. Box 4: a kite.
  2. Box 5 holds the star, so Bo stops.
  3. Boxes 6, 7 and 8 never need opening. Bo opened 5 boxes.

Example 2: Count the boxes

  1. Jonah wants the shell. It is in box 3.
  2. Bo opens box 1, box 2 and box 3, and stops.
  3. He opened 3 boxes.

Example 3: Not in the list

  1. Jonah wants a rocket sticker, and Bo opens every box from one to eight, in order.
  2. None of them holds a rocket.
  3. Every box was checked once, so the rocket is not in the list. Bo opened 8 boxes.

Example 4: Going round in circles

  1. Jonah opens box five, then box two, then box five again.
  2. Opening at random can open one box twice and miss another.
  3. Going in order fixes it.

Words to know

list
Things in a row, like the eight boxes.
search
To look through a list for one thing.
in order
One at a time, from the first.
not in the list
Every box was checked and it was not there.

Watch out

Try it

  1. The sticker is in box 6, and Bo goes in order. How many boxes does he open?
  2. Bo opens all 8 boxes and finds no rocket. What does he say?
  3. Should Jonah open the boxes in order, or at random?
  4. Once you find it, do you keep looking?
Answers: 1. 6 · 2. It is not in the list · 3. In order · 4. No, you stop
Try at homeLine up eight cups in a row, numbered with small paper tags. Hide a coin under one. Ask a grown-up to lift the cups one at a time, in order, and stop when they find it. Count how many cups they lifted. Then swap, and hide nothing once. What should they say at the end?
For grown-upsPlay the Mission: line up eight cups in a row with paper number tags and hide a coin under one. Lift the cups one at a time, in order, and stop when you find it, then count how many you lifted. Then swap, and once hide nothing: what should the searcher say at the end?
Open these notes on screenScan the code, or go to tutorpip.com.