0% found this document useful (0 votes)
45 views8 pages

6.3 Testing - Trace Tables

adada

Uploaded by

james
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views8 pages

6.3 Testing - Trace Tables

adada

Uploaded by

james
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

TRACE TABLES

WHAT IS A TRACE TABLE


Trace tables are a manual way to read and check an algorithm they are done so that
errors (logic or other) can be found in code

GETTING STARTED STEPS 1 - 3


There are 3 steps to a successful Trace table
Step 1
Number all of the executable lines in the code
i.e. not the spaces

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

while (value1 < value2)


total = total + value1
value1 = value1 + 1

output total
End

EXAMPLE

STEP
2
Step 2

Inputs
value1 = 2,

value2 = 6

Enter the start values


line

value1

value2

value1 < value2

total

Begin
1
2

2
6

1
2

Begin
read in value1
read in value2

total 0

4
5
6

while (value1 < value2)


total = total + value1
value1 = value1 + 1

output total
End

EXAMPLE

STEP
3
Step 3

Inputs
value1 = 2,

value2 = 6

Go through the algorithm line by line as needed


line

value1

value2

value1 < value2

total

1
2

Begin
read in value1
read in value2

total 0

4
5
6

while (value1 < value2)


total = total + value1
value1 = value1 + 1

output total
End

Begin
1

3
4

True

5
6

ANSWERS
Step 3

Inputs
value1 = 2,

value2 = 6

Go through the algorithm line by line as needed


line

value1

value2

value1 < value2

total

1
2

Begin
read in value1
read in value2

total 0

4
5
6

while (value1 < value2)


total = total + value1
value1 = value1 + 1

output total
End

Begin
1

3
4

True

5
6

True

5
6

4
5

5
4

True
9

You might also like