A trace table is a technique used to test algorithms in order to make sure that no logical errors occur while the
calculations are 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 input 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 certain calculations work and the systematic process that is occurring when an algorithm is executed. They can also be useful for debugging applications, helping the
programmer
A programmer, computer programmer or coder is an author of computer source code someone with skill in computer programming.
The professional titles Software development, ''software developer'' and Software engineering, ''software engineer' ...
to easily detect what error is occurring, and why it may be occurring.
Example
int i, x = 0;
for (i = 1; i <= 10; i++)
This example shows the systematic process that takes place whilst the algorithm is processed. The initial value of ''x'' is zero, but ''i'', although defined, has not been assigned a value. Thus, its initial value is unknown. As we execute the program, line by line, the values of ''i'' and ''x'' change, reflecting each statement of the source code in execution. Their new values are recorded in the trace table. When ''i'' reaches the value of ''11'' because of the ''i++'' statement in the ''for'' definition, the comparison ''i <= 10'' evaluates to false, thus halting the loop. As we also reached the end of the program, the trace table also ends.
See also
*
Algorithms
In mathematics and computer science, an algorithm () is a finite sequence of mathematically rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for per ...
*
Programming languages
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their syntax (form) and semantics (meaning), usually defined by a formal language. Languages usually provide features ...
*
Debugging
In engineering, debugging is the process of finding the Root cause analysis, root cause, workarounds, and possible fixes for bug (engineering), bugs.
For software, debugging tactics can involve interactive debugging, control flow analysis, Logf ...
References
* http://www.comscigate.com/tutorial/KjellStyle/WilliamChen/trace1.html
* http://www.thevickerage.worldonline.co.uk/theteacher/alevel/assem/assem5.htm
archived version* http://portal.newman.wa.edu.au/technology/12infsys/html/KWH2003/TraceTables.htm
Debugging
{{Algorithm-stub