You are on page 1of 17

Trace tables

A thorough structured approach is required to find out the purpose of an algorithm, which
involves recording and studying the results from each step in the algorithm.

A trace table can be used to record the results from each step in an algorithm; it is used to
record the value of an item each time that it changes. This manual exercise is called dry run.

Dry running of flowcharts is basically a technique to;

Determine the output for a known set of data to check it carries out the task
correctly.
Check on the logic of the algorithm.
Determine the function of the algorithm.

Advantages of drawing a trace table to dry run a flowchart:

If you make a mistake, it is easier to back track to where the error occurred rather
than starting from the beginning again.
There is less chance of an error being made.
Encourage a more logical approach.
Trace Table Questions:
1.) The flowchart inputs the size of a number of car engines; a value of –1 stops the
input.
This information is output: average engine size and number of engines with size > 1.5
Complete the trace table for the input data.

1.8, 2.0, 1.0, 1.3, 1.0, 2.5, 2.0, 1.3, 1.8, 1.3, –1
2.) The flowchart below inputs the weight of a number of parcels in kilograms. Parcels
weighing more than 25 kilograms are rejected. A value of –1 stops the input.
The following information is output: the total weight of the parcels accepted and
number of parcels rejected.
3.) The flowchart below inputs the height of children who want to ride on a
rollercoaster. Children under 1.2 metres are rejected. The ride starts when eight
children have been accepted.
4.) This flowchart inputs the weight of items in kilograms to be loaded on a trailer. Any
item over 25 kilograms is rejected. The trailer can take up to 100 kilograms.
5.) This flowchart inputs a range of temperatures in degrees Fahrenheit. As each
temperature is input, it is compared with the previous highest temperature. If it is
higher than the current highest, it replaces the previous highest temperature and
then it is converted to degrees Celsius.

For ease of calculation, the final step of the Fahrenheit to Celsius conversion has
been approximated as division by 2.

When –1 is entered, the input process stops and the highest temperature (in both
Fahrenheit and Celsius) is output.

You might also like