6.3 Testing - Trace Tables
6.3 Testing - Trace Tables
Step 2
Draw the data table and enter the start values
This may take 3 lines
Step 3
Go through the algorithm line by line as needed
This may take many lines
EXAMPLE
Consider this Algorithm
Inputs
value1 = 2,
Begin
read in value1
read in value2
total 0
while (value1 < value2)
total = total + value1
value1 = value1 + 1
output total
End
value2 = 6
EXAMPLE STEP 1
Inputs
value1 = 2,
Step 1
Number all of the executable lines in the code
value2 = 6
1
2
Begin
read in value1
read in value2
total 0
4
5
6
output total
End
EXAMPLE
STEP
2
Step 2
Inputs
value1 = 2,
value2 = 6
value1
value2
total
Begin
1
2
2
6
1
2
Begin
read in value1
read in value2
total 0
4
5
6
output total
End
EXAMPLE
STEP
3
Step 3
Inputs
value1 = 2,
value2 = 6
value1
value2
total
1
2
Begin
read in value1
read in value2
total 0
4
5
6
output total
End
Begin
1
3
4
True
5
6
ANSWERS
Step 3
Inputs
value1 = 2,
value2 = 6
value1
value2
total
1
2
Begin
read in value1
read in value2
total 0
4
5
6
output total
End
Begin
1
3
4
True
5
6
True
5
6
4
5
5
4
True
9