Trace Table
Trace Table Definition
Trace tables are used to follow algorithms and
make sure they perform the required task
correctly. Test data is usually used in
conjunction with a trace table to ensure the
correctness of the algorithm. Manually tracing
an algorithm with test data in this way is known
as a dry run.
Purpose of Trace Table:
• Trace tables can be used with flowcharts or pseudocode
or even real code if necessary
• Trace tables can also be used to discover the purpose of
an algorithm by showing output data and intermediary
steps
• Trace tables record the state of the algorithm at each
step or iteration. The state includes all variables that
impact the algorithms output as well as the output itself
• A trace table is composed of columns where each variable
and the output is a column
• Whenever a value changes or an output is produced the
relevant column and row is updated to reflect the change
Example 1
Complete the trace
table for the given
data. N=2
N OUTPUT
Example 2
Example 2
START
A0
B0
C 100
Input X
Example 3 X > B?
Yes
BX
A B
Class Activity-Worksheet 9 –Q1
Complete the trace table for the input data.
C X OUTPU
4 , 3, 2, 1, 0, -2 T No
X< Yes
C? CX
No
A A +1
No
Yes A < 6?
Output B, C
END
START
A0
B0
C 100
Input X
Example 3 X > B?
Yes
BX
A B
Class Activity-Worksheet 9 –Q1
Complete the trace table for the input data.
C X OUTPU
4 , 3, 2, 1, 0, -2 T No
Yes
0 0 100
X<
C? CX
1 4 4 No
A A +1
2 3 3 No
Yes
3 2 2 A < 6?
4 1 1
5 0 0 Output B, C
6 -2 -2 4 -2 END
HW- Trace Table worksheet