What is Trace table?
A table that records how the values of variables change as a program is executed line by line by hand. It is used to check the number of iterations and the final values and to locate mistakes. Because it is done on paper, it is also called desk checking.
Japanese name: トレース表
Trace table appears in 1 practice question across 1 topic, including Programming Basics (Pseudocode Tracing).
Field: Programming Basics (Pseudocode Tracing)
Making a trace table
List the variables and the truth values of conditions as columns, and fill in their values one row at a time in execution order. For a program that starts with x ← 1 and repeats x ← x × 3 while x < 100, the x column changes 1, 3, 9, 27, 81, 243, and the condition becomes false on the sixth test. Writing only the variables whose values change keeps the table easy to read.
FAQ
How does tracing differ from stepping through a program in a debugger?
Both follow the behavior line by line, but a trace table is done by a person on paper, while a debugger actually runs the program, pausing it as it goes. In an exam there is no environment to run programs, so the ability to check with a trace table is essential.
Must a long loop be traced in full?
Tracing the first few iterations to find the pattern in how the values change often lets you calculate the rest. Always check the last iteration and the exit condition, however, to avoid off-by-one errors.