Trace Table Practice Questions for Cambridge IGCSE Computer Science
Practice trace table questions designed specifically for the Cambridge IGCSE (0478/0984) and A-Level (9618) Computer Science exams. Each question includes pseudocode with a trace table for you to complete, along with step-by-step worked answers. Use PseudoStudio's built-in compiler to run the pseudocode and verify your trace table answers instantly.
Custom Dry Run Ready
IGCSE 0478/0984
20 Marks
ESTIMATED MARKS
15 Mins
TARGET TIME
🔒 Free 1-click Google Sign-in to unlock and save progress
How Cambridge Trace Tables Work (Paper 2)
In Cambridge Computer Science exams, you are presented with a pseudocode algorithm and a blank trace table grid. Here is a live example of how values are recorded:
Total ← 0FOR I ← 1 TO 3 Total ← Total + (I * 2)NEXT IOUTPUT "Final Total:", Total
| Iteration / Line | I | Total | OUTPUT |
|---|---|---|---|
| Line 1 | — | 0 | — |
| Loop Pass 1 (I=1) | 1 | 2 | — |
| Loop Pass 2 (I=2) | 2 | 6 | — |
| Loop Pass 3 (I=3) | 3 | 12 | — |
| Line 5 | — | — | "Final Total: 12" |
How to Answer Trace Table Questions
Completing a trace table accurately requires method and patience. Missing a single variable update can cause cascading errors. Follow these steps for Cambridge Computer Science exams (IGCSE 0478 and A-Level 9618):
- Read the entire code first: Understand the algorithm's purpose before tracing. Identify all variables and loops.
- Set up the columns: If not provided, create a column for every variable, condition, and output.
- Execute line by line: Follow the code exactly as a computer would. Do not skip steps.
- Record changes only: You only need to write a new value in a column when that variable's value changes. Use a dash (–) or leave it blank if the value remains the same as the previous step.
- Watch for loop conditions: Pay close attention to when a `WHILE` or `REPEAT...UNTIL` loop terminates.
- Track the exact OUTPUT: Ensure you record the output exactly as it would appear on screen, including strings and variables.
Trace Table Practice Questions
Try solving these trace tables on paper first, then click "Show Answer" or run the code in PseudoStudio to verify.
Question 1: Simple FOR Loop (Easy)
Complete the trace table for the following algorithm.
DECLARE Num : INTEGER
DECLARE Total : INTEGER
Total ← 0
FOR Count ← 1 TO 3
Num ← Count * 5
Total ← Total + Num
NEXT Count
OUTPUT Total
👁️ Show Worked Answer
| Count | Num | Total | OUTPUT |
|---|---|---|---|
| - | - | 0 | - |
| 1 | 5 | 5 | - |
| 2 | 10 | 15 | - |
| 3 | 15 | 30 | - |
| - | - | - | 30 |
Question 2: WHILE Loop with Condition (Medium)
Trace the following algorithm using the input values: 5, 8, -1.
DECLARE Value : INTEGER
DECLARE Max : INTEGER
Max ← 0
INPUT Value
WHILE Value <> -1 DO
IF Value > Max THEN
Max ← Value
ENDIF
INPUT Value
ENDWHILE
OUTPUT "Max is ", Max
👁️ Show Worked Answer
| Value | Max | OUTPUT |
|---|---|---|
| - | 0 | - |
| 5 | - | - |
| - | 5 | - |
| 8 | - | - |
| - | 8 | - |
| -1 | - | - |
| - | - | "Max is 8" |
Question 3: Nested Loops & Arrays (Hard)
Complete the trace table for this algorithm. Assume the array Data[1:4] contains the values [3, 7, 2, 5].
DECLARE Temp : INTEGER
DECLARE Swapped : BOOLEAN
Swapped ← TRUE
WHILE Swapped = TRUE DO
Swapped ← FALSE
FOR i ← 1 TO 3
IF Data[i] > Data[i+1] THEN
Temp ← Data[i]
Data[i] ← Data[i+1]
Data[i+1] ← Temp
Swapped ← TRUE
ENDIF
NEXT i
ENDWHILE
OUTPUT "Sorted"
👁️ Show Worked Answer
This is a classic Bubble Sort trace table. Only the first pass is shown below for brevity.
| Swapped | i | Data[1] | Data[2] | Data[3] | Data[4] | Temp |
|---|---|---|---|---|---|---|
| TRUE | - | 3 | 7 | 2 | 5 | - |
| FALSE | 1 | - | - | - | - | - |
| - | 2 | - | - | - | - | 7 |
| - | - | - | 2 | - | - | - |
| - | - | - | - | 7 | - | - |
| TRUE | - | - | - | - | - | - |
| - | 3 | - | - | - | - | 7 |
| - | - | - | - | 5 | - | - |
| - | - | - | - | - | 7 | - |
Want to practice more? Generate unlimited custom trace tables instantly.
OPEN TRACE TABLE GENERATOR 🚀