trace+table

=3.2.6 e=
 * ===perform a dry run on a given algorithm, using a trace table;===


 * = KEYWORDS = || = DEFINITION = ||
 * ** Algorithm ** || A sequence of steps designed to perform a particular task ||
 * ** Dry run ** || Working through a section of a program manually ||
 * ** Trace table ** || A table constructed with a column to identify the instruction executed and columns for the contents of each variable ||
 * ** Debugging ** || The detection, location and correction of faults causing errors in a program ||
 * ** Variable ** || The identifier associated with a particular memory location used to store data ||
 * ** Constant ** || A data item with a fixed value ||

= = =Dry run= In programming, a dry run refers to 'executing' a program by hand, taking notes on paper of the program's variables and how they will change when the program is running normally. A dry run is most commonly used when you want to check a program will run in the desired way, or used as a debugging method. (For others, see this page). A dry run is only really sensible to be used with simple algorithms, as it involves running through the entire program and working out what everything does, which, if the program is large, could prove very time consuming and difficult.

Trace tables
Dry runs are most commonly executed with the help of a trace table, which is a method of plotting the variables of the programs and how they change depending on the inputs, for example, if a program were to input a value of 'Y', perform a multiplication of 2 on it, and output 'X', the trace table for a dry run on this algorithm would look like this:

int x=0; input y; x = y * 2; output = x;


 * = ==__Y__== ||= ==__X__== ||
 * = ==1== ||= ==2== ||
 * = ==2== ||= ==4== ||
 * = ==3== ||= ==6== ||
 * = ==4== ||= ==8== ||

This is a very very simple algorithm, but you can see how a trace table would help plot out a program to see if it worked in the desired way, and to quickly see how it works.

= PRACTISE EXAM QUESTIONS = = = =  =