Pseudocode and trace tables
Pseudocode describes an algorithm; a trace table follows it line by line.
Reading pseudocode
Look for the inputs, the loop and the condition that ends it, and what is output. Most questions use a handful of structures: assignment, IF, a counted loop, a condition-controlled loop and arrays.
| Structure | Looks like |
|---|---|
| Assignment | total ← 0 |
| Selection | IF … THEN … ELSE |
| Counted loop | FOR i ← 1 TO 10 |
| Condition loop | WHILE x < 5 |
| Array | names[3] |
Trace tables
Give each variable its own column and add a row every time a value changes. Work slowly: most lost marks come from skipping a line.
| Line | i | total |
|---|---|---|
| 1 | 0 | |
| 2 | 1 | 0 |
| 3 | 1 | 1 |
| 2 | 2 | 1 |
| 3 | 2 | 3 |
Then write it as code
Python lessonsWrite it as real code, in your browser
Printable pseudocode guideIn the Shop Questions
Is there one correct pseudocode?
No. Exam boards publish their own style, but any clear, logical pseudocode can get the marks. Use the style your board shows in its papers.
Related
Helps with GCSE computer science (AQA, Pearson Edexcel and OCR). AQA, Pearson Edexcel and OCR are trade marks of their owners. Brainlag is independent and is not affiliated with or endorsed by any exam board.