All subjects · Mathematics · WDM11 (D1)
Algorithms, flow charts and trace tables
An algorithm is a finite sequence of precise instructions that solves a problem. D1 starts by asking you to follow algorithms exactly, written as text or as flow charts, and record what happens in a trace table.
What makes an algorithm
An algorithm must be finite (it stops), precise (each step has one meaning) and give an output from its input. Exam questions give you the algorithm: you do not need to invent one, but you must follow it exactly, even if you can see a shortcut.
Flow charts
Flow charts use three box shapes:
- rounded box (oval): start or stop
- rectangle: an instruction (for example, let A = A + 2)
- diamond: a decision with two exits, yes and no
Follow the arrows. A loop is a path that returns to an earlier box.
Trace tables
Give each variable a column and write one row each time a value changes or a decision is made. Write every row out in full; do not compress repeated steps. State the final output clearly, and keep any rounding the question asks for.
What does it do?
A common last part asks what the algorithm achieves. Try it on the given input, look at the output, and describe the link in general terms (for example: it finds the highest common factor of A and B, or it multiplies the two inputs).
Worked example
Russian peasant multiplication. Write A = 37 and B = 21. Repeatedly halve A (ignoring remainders) and double B until A = 1. Add the B values in rows where A is odd.
- Rows (A, B): (37, 21); (18, 42); (9, 84); (4, 168); (2, 336); (1, 672)
- A is odd in the rows (37, 21), (9, 84), (1, 672)
- Add those B values: 21 + 84 + 672 = 777
Answer: Output 777, which is 37 × 21: the algorithm multiplies the two numbers
Check yourself
- Use Russian peasant multiplication (halve A ignoring remainders, double B, add B where A is odd) with A = 25 and B = 14. What is the output?
Show answer
350. Rows: (25, 14); (12, 28); (6, 56); (3, 112); (1, 224). A is odd in rows with B = 14, 112, 224, total 350.
- An algorithm takes A and B. While B is not 0: let R be the remainder when A is divided by B, then let A = B and B = R. Output A. Find the output when A = 252 and B = 105.
Show answer
21. Rows (A, B, R): (252, 105, 42); (105, 42, 21); (42, 21, 0). B becomes 0, so the output is A = 21.
- What does the algorithm in the previous question (repeatedly replace A, B by B and the remainder of A ÷ B) find?
- The lowest common multiple of the two numbers
- The quotient A ÷ B
- The number of times B divides A
- The highest common factor of the two numbers
Show answer
The highest common factor of the two numbers. 252 = 22 × 32 × 7 and 105 = 3 × 5 × 7, whose highest common factor is 21, matching the output 21. This is Euclid's algorithm.
- Step 1: let A = 45 and C = 0. Step 2: if A is even let A = A/2, otherwise let A = A - 1. Step 3: let C = C + 1. Step 4: if A > 1 go to Step 2, otherwise output C. What is the output?
Show answer
8. A goes 45, 44, 22, 11, 10, 5, 4, 2, 1, taking 8 times round the loop, so C = 8.
- In a flow chart, which box shape shows a question such as 'Is A > B?'
- A rectangle
- A rounded box
- A diamond
- A circle
Show answer
A diamond. Decisions use a diamond with a yes exit and a no exit.
- An algorithm starts with A = 1 and B = 1 and outputs A. It then repeats: let C = A + B, let A = B, let B = C, output A. What is the 10th number output?
Show answer
55. The outputs are 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, so the 10th is 55.
- Which property must every algorithm have?
- It must use a flow chart
- It must sort a list
- It must stop after a finite number of steps
- It must use a computer
Show answer
It must stop after a finite number of steps. An algorithm is a finite sequence of precise instructions, so it must terminate.
Sources
- Pearson Edexcel International Advanced Level in Mathematics specification (issue 3)
- Pearson Edexcel IAL Decision Mathematics 1 scheme of work
Last updated 7 November 2026. Spotted a mistake? Tell us.