Chapter 02

Following Steps — What Is an Algorithm?

Kindergarten
At a glance
Core ideaAn algorithm is a list of steps done in a set order to finish a job.
Key termSequence — each step leads to the next, from a clear start to a clear end.
You can…Break an everyday task into ordered, unambiguous steps.
Watch outThe same steps in the wrong order can break the whole result.
Theory

A list of steps done in order to finish a job is called an algorithm. You already know lots of algorithms! Brushing your teeth is an algorithm: wet the brush, add toothpaste, brush the top teeth, brush the bottom teeth, rinse, done.

Every algorithm needs a clear start and a clear end, with each step leading naturally to the next one.

Start Put on pyjamas Brush teeth End EACH STEP RUNS IN ORDER, ONE AFTER THE OTHER
An algorithm is a clear start, a set of steps done in order, and a clear end.
Explanation

Order matters enormously. Put your shoes on before your socks, and something goes wrong — even though "socks" and "shoes" are both still in your steps! The same steps in the wrong order can turn a good algorithm into a broken one. This is why people who write instructions for computers are so careful about the order they write things in.

Big idea. An algorithm is not just a list of things to do — it is a list of things to do in a particular order.

Practical

Activity: Sequence the Story. Draw four pictures on separate cards: "wake up," "get dressed," "eat breakfast," "brush teeth." Mix the cards up, then put them back into an order that makes sense.

Now swap two of the cards — say "get dressed" and "brush teeth" — and act out what silly thing would happen if you really did the steps in that broken order.

Q&A
Q1 What is an algorithm, in your own words?

An algorithm is a list of steps, done one after another in order, that finishes a job. A recipe, a set of directions to a friend's house, and instructions for a board game are all algorithms.

Q2 Can you name an algorithm you follow every day?

Yes — getting ready for bed is a good example: put on pyjamas, brush teeth, read a story, turn off the light. Each step happens in a set order, every night.

Q3 What happens if you do the steps of an algorithm out of order?

It usually breaks! Some algorithms simply don't work if you swap steps — like trying to put your shoes on before your socks. This is exactly why computers, which follow algorithms exactly, need the steps written in the right order.

Concept mind map

How the ideas connect

Every key idea in this chapter, branching from the core concept — use it to see the whole picture at a glance.

ordered stepsclear startclear endsequenceeach step leads onunambiguousWhat is an algorithm
Infographic

The process, step by step

Step 1StartBegin at a clear first step with everything you need ready.
Step 2Do a stepCarry out one small, exact instruction.
Step 3Move onGo to the next step in order; each step leads to the next.
Step 4FinishStop at a clear end when the job is done.
Solved examples

Worked problems, step by step

Follow each solution line by line, then try to reproduce it on paper before moving on.

Example 1Write an algorithm to brush your teeth.

  1. 1. Pick up the toothbrush.
  2. 2. Put toothpaste on it.
  3. 3. Brush for two minutes.
  4. 4. Rinse and put the brush away.

Example 2These steps are out of order: pour milk, get a glass, drink. Fix the order.

  1. You need the glass before you can pour.
  2. You must pour before you can drink.
Practice problem set

Now you try

Work each one out first, then tap to reveal the worked answer.

1What is an algorithm?
A list of steps done in a set order to finish a job, from a clear start to a clear end.
2Why does the order of steps matter?
Each step leads to the next; doing them out of order can make the job fail, like pouring milk before getting a glass.
3What does unambiguous mean for a step?
It means the step has only one clear meaning, so the computer cannot misread it.
4Give an everyday example of an algorithm.
A recipe is an algorithm: ordered steps that turn ingredients into a finished dish.
5What makes a good algorithm?
Every step is exact, in the right order, with a clear start and a clear end and nothing left out.
6Can two different algorithms do the same job?
Yes. There is often more than one correct set of ordered steps to reach the same result.