A recipe is a program for people
You follow steps to make a cup of tea. Boil the water. Put a tea bag in a cup. Pour the water. Wait. Take the bag out.
If you change the order, the tea goes wrong. A list of steps in the right order is an algorithm: a list of clear steps that solves a problem.
Key words
| Word | What it means | Example |
|---|---|---|
| Algorithm | A list of clear steps in order that solves a problem. | a recipe |
| Flowchart | A picture of an algorithm made of shapes and arrows. | start, check age, end |
| Terminator | The shape for Start and End. | a rounded box |
| Process | The shape for one thing to do. | add 1 to the score |
| Sub-process | The shape for a job that has its own flowchart. | check the password |
| Decision | The shape for a question with two answers. | is it raining? |
| Sequence | Steps one after another, in order. | wake up, wash, eat |
| Selection | Choosing a path by asking a question. | if it rains, take an umbrella |
| Iteration | Repeating steps. | knock until the door opens |
| Loop | Another name for iteration. | repeat until the door opens |
The cells students fill in are left blank in this preview.
Is it an algorithm?
Have a go
Is it an algorithm?
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
What makes a good algorithm
| It is... | This means... | Example |
|---|---|---|
| Clear | Each step has only one meaning. | "Add 2" not "add a bit" |
| In order | The steps are in the right order. | Boil the water before you pour it |
| Finite | It ends after a fixed number of steps. | It does not run for ever |
| Has inputs and outputs | It takes in data and gives a result. | In: age. Out: ticket price |
| Correct | It solves the whole problem. | It works for a child and an adult |
The cells students fill in are left blank in this preview.
Why write an algorithm first?
A computer cannot guess. It does exactly what the steps say. Nothing more.
If you write the algorithm first, you find mistakes before you write code. You can also show the plan to other people.
Arrows and labels
Arrows show the order. Follow them from Start to End.
A decision has two arrows out. Each arrow has a label, such as yes or no. The circle with a letter is a connector. It joins two parts of a chart that are far from each other.