Pseudocode and Flowcharts
Algorithm Design and Problem Solving · 4 question types
Exam Frequency Analysis
Past paper frequency (2018 to 2024)
This topic accounts for approximately 11% of your exam marks.
The most marks-dense topic. Both papers test pseudocode writing and trace tables every sitting.
A trace table is a table used to record the value of each variable at every step of an algorithm, so that the algorithm can be hand-executed and checked for correctness.
Trace tables are essential for finding logic errors, where a program runs without crashing but produces the wrong output. By stepping through the algorithm with specific test data, the programmer can spot the exact step where the variables go wrong.
An algorithm like the "find the highest of ten numbers" flowchart below, with a counter and a decision inside a loop, is a typical candidate for a trace table:

How to set up a trace table
- List the variables the algorithm uses as column headings. Include any output as the last column.
- Number the rows (optional, but useful for long algorithms).
- Walk through the line by line, updating the relevant column whenever a variable changes.
- Note any output in the OUTPUT column when an
OUTPUTstatement is reached. - Continue until the algorithm finishes (the loop terminates or the program reaches END).
Why trace tables are useful
- Finding logic errors: if
Highestdoes not update when it should, the trace table reveals the exact step where the bug is. - Verifying loop termination: walking through the loop counter line by line shows that the loop ends when it is meant to.
- Understanding unfamiliar algorithms: a trace table forces a careful, step-by-step reading and often makes the purpose of the algorithm obvious.
- Picking suitable test data: tracing with boundary and abnormal data (topic 18) checks the program's edge cases.
Complete the trace table for this algorithm
The algorithm below reads four numbers one at a time and accumulates a running total. Complete the trace table for the inputs 3, 7, 2, 8 in that order.
Total ← 0
FOR i ← 1 TO 4
INPUT Num
Total ← Total + Num
NEXT i
OUTPUT Total
Solution:
| i | Num | Total | OUTPUT |
|---|---|---|---|
| — | — | 0 | |
| 1 | 3 | 3 | |
| 2 | 7 | 10 | |
| 3 | 2 | 12 | |
| 4 | 8 | 20 | |
| — | — | — | 20 |
Key points when filling in a trace table:
- Only update a column in the row where that variable actually changes — leave all other cells blank.
- Record OUTPUT only when the
OUTPUTstatement is reached (after the loop ends here). - The loop counter
iupdates at the start of each iteration;NumandTotalupdate in that same pass through the loop body.