Trace table
From Wikipedia, the free encyclopedia
A trace table is a technique used to test algorithms, in order to make sure that no logical errors occur whilst the algorithm is being processed. The table usually takes the form of a multi-column, multi-row table; With each column showing a variable, and each row showing each number inputted into the algorithm and the subsequent values of the variables.
Trace tables are typically used in schools and colleges when teaching students how to program, they can be an essential tool in teaching students how a certain algorithm works and the systematic process that is occurring when the algorithm is executed.
They can also be useful for debugging applications, using a trace table can help a programmer easily detect what error is occurring, and why it may be occurring.
[edit] Example
- x = 0
- For i = 1 to 10
- x = x+i
- Next i
i x 1 1 2 3 3 6 4 10 5 15 6 21 7 28 8 36 9 45 10 55
This example shows the systematic process that takes place whilst the algorithm is processed, as the values of i and x change, their new values are recorded in the trace table, this example shows why trace tables are useful for debugging and in education, they make following an algorithmic process easy to follow and understand.