Trace Tables & Algorithm Dry-Run Execution

A dry run follows an algorithm manually, tracking variables, condition results and output. Use the row convention stated in the task. Some tables record each change; others request snapshots at particular points. Do not invent a universal marking penalty for repeated values.

Worked snapshots

This example records initial values, then a snapshot after each complete loop body, followed by output. Unchanged values repeat because these are snapshots.

DECLARE Sum, Count : INTEGER
Sum <- 0
Count <- 1
WHILE Count <= 3 DO
    Sum <- Sum + Count
    Count <- Count + 1
ENDWHILE
OUTPUT Sum

Event

Count

Sum

Output

Initialisation

1

0

After iteration 1

2

1

After iteration 2

3

3

After iteration 3

4

6

Final output

4

6

6

At Count = 4, the condition is false so the body does not run again. The update to Count happens after adding it to Sum, which explains why the first post-body row has Count = 2 but Sum = 1.

For a change-only table, record each assignment when it occurs and leave unaffected cells empty. Always preserve earlier entries, include initialisation where requested and record output exactly. Trace the exercises before using the interpreter to check your reasoning.

AI Socratic Tutor

All-Access
Sign in or create an account. AI Tutor is an All-Access benefit.
Sign Up

Need guidance? Ask a question or use the hint below.

AI Socratic Tutor is an All-Access Benefit

Unlock step-by-step Socratic hints, algorithm trace table walkthroughs, and error diagnostics for every Cambridge exercise.

You're chatting with an AI tutor, not a person. AI can make mistakes, so double-check its answers.

Independent Trace: Powers

+30 XP

Record five snapshots: initial values, after each of the three complete loop bodies, and after the final OUTPUT. Repeat unchanged values; leave OUTPUT empty until it executes.

// no-run
Power <- 1
Count <- 1
WHILE Count <= 3 DO
    Power <- Power * 2
    Count <- Count + 1
ENDWHILE
OUTPUT "Result: ", Power
Trace Table Matrix
# Count Power OUTPUT
1
2
3
4
5
All-Access Required

Interactive exercises for Module 2 and beyond require an active plan.

Trace Table Assertions
○ All snapshots match