Algorithms Are Recipes
About this lesson, for parents and teachers
A computer can make anything if you give it the right steps in the right order. Can you write the steps for a yummy sandwich?
Ages 6–8 · about 6 minutes · builds on Robot Steps to the Apple · leads to Loops Make a Dance, Secret Codes With a Cipher Wheel, Variables Are Labeled Boxes
Try this
- Tap the recipe cards in the order you would do them. Tap a card again to take it back.
- Press Cook! The computer does your steps one by one, in order.
- If a step can't happen yet, the card turns red. Move cards around and cook again.
- In the last sandwich, try swapping cheese and tomato. Does it still work?
How it works
An algorithm is a list of steps that solves a problem. A recipe is an algorithm for food. A computer program is an algorithm written for a computer. The steps have to be clear, and they have to be in the right order. People follow algorithms all day without noticing: the steps for tying shoes, crossing a road safely or playing a board game are all algorithms.
When you press Cook, the computer reads step 1, then step 2, then step 3. It never skips ahead and it never guesses what you meant. Before each step it checks if that step can happen right now. You can't spread jam if there is no bread yet, and you can't add cheese after the sandwich is closed.
Some steps must come before others. Bread has to go down before the jam. But some steps can swap places. Cheese then tomato makes the same sandwich as tomato then cheese. Good programmers notice which steps depend on each other and which ones don't. When you build the cheese and tomato sandwich, try both orders and see that the computer is happy with either one.
Putting steps in order like this is called sequencing. It is the very first skill in coding, and you use it every day when you get dressed, brush your teeth or follow a game's rules. Before you write any program, it helps to say the steps out loud in order, just like reading a recipe before you start cooking.
Where engineers use this
Robots in car factories follow strict step-by-step algorithms, and a delivery app follows an algorithm to decide which order to drop off packages.
Words to know
- Algorithm
- A list of steps, in order, that gets a job done.
- Sequence
- The order that steps happen in.
- Step
- One small instruction, like spread jam.
Talk about it
Goal: Put the steps of making a sandwich in order and learn what an algorithm is.
- What happens if you put your shoes on before your socks? Which steps have to come first?
- In the last sandwich, cheese and tomato could swap. Can you think of other steps that can go in any order?
- If you had to teach a robot to brush its teeth, what would step 1 be?
Without a screen: Make a real sandwich together, but your child is the programmer and you are the robot. Do exactly what they say and nothing more (if they say put bread on the plate without saying take it out of the bag, try to do it literally). Laugh, fix the steps, and try again.
Curriculum links: CSTA K-12 1A-AP-08 (model daily processes by creating and following algorithms); CSTA K-12 1A-AP-10 (programs with sequences)
Questions
What is an algorithm in simple words?
An algorithm is a set of steps you follow, in order, to get something done. A recipe, the directions to a friend's house and a computer program are all algorithms.
What is a good algorithm activity for grade 1?
Sequencing activities work well: cut a familiar routine like making a sandwich into picture cards and ask your child to put them in order, then test the order by acting it out.
Why does the order of steps matter in coding?
A computer does exactly what the steps say in exactly the order you give them. If a step comes too early, like spreading jam before there is bread, the program fails or does something silly.