Knowledge Organiser: Trace Tables and Pseudocode Syntax
Key Terms
- Trace table: A table used to track the value of variables at each step of an algorithm
- Dry run: Manually stepping through an algorithm (using a trace table) without running it on a computer
- Assignment: Giving a variable a value (e.g. score = 0)
- Iteration: Repeating a block of code (FOR loop or WHILE loop)
- Selection: Choosing between paths using IF…THEN…ELSE…ENDIF
- Comparison operators: == (equal), != (not equal), < > <= >= (less/greater)
Must-Know Facts
- Trace tables have one column per variable plus an output column
- Each row records variable values AFTER executing one line or iteration
- FOR loop: for i = 1 to 10 … next i (runs a fixed number of times)
- WHILE loop: while condition … endwhile (runs while condition is true)
- String operations: string.length, string.substring(start, length), string.upper
- Logical operators used in conditions: AND, OR, NOT
Key Concepts
- Trace table: column per variable → fill in values row by row as algorithm executes
- IF needs ENDIF; FOR needs NEXT; WHILE needs ENDWHILE — always close what you open
- Pseudocode comparison: == (equal to), != (not equal to), <= (less than or equal)
- Use trace tables in exams to show understanding of algorithm behaviour with given inputs
Common Mistakes
- Only writing the final variable values: A trace table must show variable values after EVERY step or iteration — skipping intermediate rows loses marks
- Missing the output column: If an algorithm includes a print/output statement, the trace table must have an output column — forgetting it is a very common omission
- Updating all variables in one row simultaneously: Variables are updated one line at a time — each assignment gets its own row; copying a previous value into later rows when it hasn't changed is also expected
- Using = instead of == in conditions: In pseudocode, == is comparison and = is assignment — writing conditions with = instead of == shows a misunderstanding of the syntax
- Forgetting closing keywords in pseudocode: IF must end with ENDIF, FOR with NEXT, WHILE with ENDWHILE — omitting closing keywords in written answers loses structure marks