Standard Algorithm Structures · Cambridge syllabus 7.9, 8.1 · Lesson 1 of 3
Sequence
Sequence executes instructions in their written order. Later statements can depend on values computed earlier. Reordering statements may change the result even if the same statements remain present.
By the end, you can
- Understand that instructions can execute in order.
- Trace sequential algorithms.
- Design algorithms using ordered instructions.
Sequential execution
Sequence is the simplest control structure: the instructions are carried out one after another, in the order they are written, each exactly once. Nothing is repeated and nothing is skipped.
The order is part of the meaning, and rearranging it usually breaks the algorithm. Total ← 0 must come before Total ← Total + Mark, or the total starts with whatever happened to be in memory. A value must be input before it is used, and a result must be calculated before it is output.
A useful test is to ask of each step what it depends on. Any step that uses a value must come after the step that produced it, and those dependencies fix the order. Where two steps depend on nothing from each other, their order genuinely does not matter.
A purely sequential algorithm is only enough for a problem with no conditions and no repetition — converting a temperature, calculating an area, working out a total price. Everything else needs selection or iteration, but the sequence within each of those blocks still runs in order.
Worth remembering
- Instructions run once each, in the order written.
- A step that uses a value must come after the step that produced it.
- Enough on its own only for problems with no conditions and no repetition.
Worked example
X ← 4 then Y ← X + 1 gives Y = 5; Y cannot use the new value of X before X is assigned.
Practice
Warm-up · not marked
Check your understanding
Answer in your own words, then compare with the worked answer. Nothing here is saved or scored.
Worked answer
B remains 3; the assignment copied the earlier value of A.
Check your method, units and explanation against it.
Marked practice
Set 1 of 4 · easiest first · Checked as you go, with the worked answer. Sign in or create a free account to save your progress.