- Home
- Lessons
- GCSE & IGCSE Computer Science
- Algorithms and flowcharts
Algorithms and flowcharts
🎬 The doodle video for this lesson is coming soon. Subscribe on YouTube to see it first.
An algorithm is a precise set of steps to solve a problem. Every program is built from three basic structures.
Three building blocks
Sequence: steps run one after another in order.
Selection: a decision chooses which steps run, such as IF ... ELSE.
Iteration: steps repeat, using a loop such as FOR or WHILE.
Selection: a decision chooses which steps run, such as IF ... ELSE.
Iteration: steps repeat, using a loop such as FOR or WHILE.
Flowchart symbols
Flowcharts show algorithms visually.
Tracing an algorithm
A trace table follows the value of each variable step by step. It is the best way to find out what an algorithm does or where it goes wrong.
What is output? total = 0. FOR i FROM 1 TO 4: total = total + i. OUTPUT total.
- i = 1: total = 1
- i = 2: total = 3
- i = 3: total = 6
- i = 4: total = 10
Answer: 10
Algorithms use sequence, selection and iteration. Flowchart symbols: oval for start and end, rectangle for process, diamond for decision, parallelogram for input and output. Trace tables track variables.
The interactive lesson includes the diagrams for this topic.
Check you have got it
Answer 6 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.