boat

Trace tables

process checking

Big software houses split tasks amongst various staff.

Algorithm Engineers develop algorithms to solve coding problems using pseudocode, flowcharts etc.
Test engineers identify suitable test data to run through the algorithm, checking the results against predicted results. If the results don't match, the algorithm is refined by the Algorithm Engineers.
Programmers take the refined algorithms and develop the program code.

This unit will look at the job of the test engineers. This is the link between the algorithm engineers and the actual coders. Their job is critical to the success of a project.

Scenario

An accountancy firm requires software that will allow a user to input tax data and output the total tax entered, the average tax, the number of tax data items entered. The program will terminate when the user enters -1.

An Algorithm engineer has produced the following pseudocode to solve the problem:

total ← 0

count ← 0

OUTPUT "Enter a tax amount: "

taxAmount ← USERINPUT

WHILE taxAmount <> -1 DO

total ← total + taxAmount

count = count + 1

OUTPUT "Enter a tax amount: "

taxAmount ← USERINPUT

END WHILE

average = total/count

OUTPUT "Total tax is ", total

OUTPUT "Average tax is ", average

OUTPUT "Number of tax items entered", count

Preparing Test Data

To test this sequence of steps, the Test Engineers have identified the following test data to be input into the algorithm:

10 5 7 15 13 20 -1

According to this data, they have already calculated their own actual results:

Total Count Average
70 6 11.67

Tracing Test Data

In order to see how the algorithm manages the test data, a trace table can be used.

A trace table lists all of the variables used in the algorithm, and traces their values as each step in the algorithm is processed.

Here is an example of a trace table for the algorithm design above:

total count taxAmount average "Total tax is " "Average tax is " "Number of items "
0 0 10
10 1 5
15 2 7
22 3 15
37 4 13
50 5 20
70 6 -1
11.67 70 11.67 6

Let's take a closer look at what's going on.

Inputs

10 5 7 15 13 20 -1

algorithm

total ← 0

count ← 0

OUTPUT "Enter a tax amount: "

taxAmount ← USERINPUT

WHILE taxAmount <> -1 DO

total ← total + taxAmount

count = count + 1

OUTPUT "Enter a tax amount: "

taxAmount ← USERINPUT

END WHILE

average = total/count

OUTPUT "Total tax is ", total

OUTPUT "Average tax is ", average

OUTPUT "Number of tax items entered", count

total count taxAmount avg "Total" "Average" "Num items "
0 0 10
10 1 5
15 2 7
22 3 15
37 4 13
50 5 20
70 6 -1
11.67 70 11.67 6