Back to computer sciencecomputing use cases

Computer ScienceComputingElementaryPrimary

How to teach algorithms

An algorithm is a list of steps, in the right order, that finishes a task. This page explains what an algorithm is for elementary students, with a free activity where a robot follows each student's steps exactly as written.

Title card reading 'How to teach algorithms', next to three chat cards: a student writes cereal steps that never get a bowl, Sparky asks whether the robot ever got a bowl before step 2, and the student says Robo didn't know what he meant, so he had to say every step.

"Flint’s adaptive responses adjust based on each student’s skill level. Because the content aligns with students’ current understanding, they become more engaged and confident in their learning."

Roselyn BaroniaRoselyn Baronia, Upper School Computer Science Teacher at Tsinglan School

Why this matters

A young student can say "an algorithm is a list of steps" and still write "make the cereal" as one step. People fill in the missing parts for them every day, so the gap never shows. On a worksheet a skipped step looks fine to the student who wrote it, and the teacher has to wait until grading to find out who left steps out.

What an algorithm is

An algorithm is a list of steps to follow in order to finish a task or solve a problem, and the steps have to be in the right order (BBC Bitesize). A recipe and a set of directions to the park are both algorithms. A computer follows an algorithm exactly as written, so students need three habits:

  • Write every step. A person knows to get out a bowl, and a computer only does it when a step says so.
  • Put the steps in order. Pouring milk before the bowl is on the table spills the milk.
  • Make each step exact. "Keep pouring" never says when to stop.

A step that is missing, out of order or vague makes the computer do the wrong thing. Programmers call that a bug, and finding and fixing it is debugging. The word "algorithm" also has a meaning in AI, covered in our AI glossary entry on algorithms. This page teaches the everyday meaning.

In the Flint activity, each student types numbered steps for an everyday task, and Sparky builds an interactive where Robo, a robot, follows those steps exactly as written. A worksheet can't act out a student's steps, and Robo stops on the first bug so the student can find and fix it.

Sparky gets Leo to find his own missing step

Leo ends up finding his own missing step and explaining why a computer needs every step written out. Everyone in the class gets the same activity, and Sparky's replies depend on each student's own steps.

Robo acts out Leo's own stepsSparky sends Leo back to a step he wroteA fix that works gets a harder task
L

Leo

Interest: Makes cereal for his little sisterStarting point: Thinks a computer knows what you mean

Leo

robots are smart, robo will know what i mean.
1. get the cereal
2. pour the cereal
3. pour the milk
4. give it to my sister

Sparky

Let me run your steps! See what happens on step 2.
An interactive Sparky made in the chat. A cartoon robot stands next to a table where a tipped cereal box has spilled cereal, with the words no bowl. Leo's four steps are listed: step 1 is green and marked worked, and step 2, pour the cereal, is red and marked BUG.
InteractiveRobo's Cereal Algorithm: Find the Missing Step

Leo

ok i fixed it. step 2 is now: pour the cereal in the bowl

Sparky

Look back at your steps. Before step 2, did Robo ever get a bowl?

Leo

oh. robo never got a bowl. and it would pour into a closed box too! new steps:
1. get a bowl from the cupboard and put it on the table
2. get the cereal
3. open the cereal box
4. pour the cereal in the bowl
5. pour the milk in the bowl
6. give the bowl to my sister

Sparky

You found TWO bugs, the missing bowl AND the closed box! Click Next Step and watch Robo nail all 6 steps this time!
The same robot interactive, run again on Leo's six new steps. A bowl sits on the table next to his sister, all six steps are green with check marks, and a box says Algorithm complete.
InteractiveRobo's Cereal Algorithm

Leo

so robo didnt know what i meant. i had to say every step

Sparky

Ready for a harder challenge? This time your steps will need something like "Stir the cereal 5 times" (repeat a step) or "If the bowl is full, stop pouring" (a rule that checks something).

Left out the bowl, fixed two bugs and explained what an algorithm is

Leo is an example student, and Sparky's replies are shortened.

What Flint did for Leo

  • Sparky built Robo from Leo's four steps, and Robo poured cereal onto the table at step 2.
  • When Leo's fix still gave Robo no bowl, Sparky asked whether Robo got a bowl before step 2.
  • After Robo ran Leo's six new steps, Sparky gave Leo a harder task needing a repeated step or if/then rule.

A teacher can't do this by hand for 30 students, and Sparky does it in every student's chat.

The activity page shows who is still leaving steps out

While the class works, Needs attention shows the teacher which student is stuck and on which message. After three or more students submit, activity analytics lists what the class did well, where students went wrong, and a follow-up to practice next.

Flint's activity page for the Teach Robo: Write an Algorithm activity. Needs attention flags a student whose Robo still has no bread for the peanut butter. Activity analytics says most students found their missing step after one run and 14 wrote an if/then rule, 8 students wrote one big step instead of small ones, and the follow-up suggests finding a partner's bug before Robo runs.

Example activity page

After a computer science class teaches Robo a task

The school and students are made up for this page.

Set up the activity for free

The Robo activity is in Flint's public library, with Sparky's role, guidelines and greeting already written. Open it, select Use activity to copy it into a free Flint account, and assign it to a class. Students type their steps in the chat, so the activity needs no robot kit or printouts.

For more computer science activities, see Flint for computer science.

Other use cases

See all use cases →

Learning feels different when it fits you.