Using Trace Tables

A trace table is a technique used to test an algorithm and predict step by step how the computer will run the algorithm. It can be used to understand or predict what an algorithm is doing and to identify potential logic errors (when the program compiles but does not produce the expected output).

The animation below demonstrate the use of a trace table used to track the values of variables as they change while the program is running. trace-table-s

Using a trace table to test an algorithm is called dry run testing.

Your Task


Check the following algorithms and complete their trace tables. (Click on any cells of these tables to add content)
Algorithm #1Algorithm #2Algorithm #3Algorithm #4

Algorithm #1: While Loop

Trace Table

 Line Numberiji < jOUTPUT
10
210
4True
51
69
4True

Algorithm #2: Factorial

Trace Table

 Line Numbernumberfactorialnumber > 2OUTPUT
15
25

Algorithm #3: Fizz-Buzz Sequence

Trace Table

 Line Numberii MOD 3 == 0i MOD 5 == 0OUTPUT
11
2FalseFalse
4False
6False
8
91
12

Algorithm #4: Max Function

Trace Table

 Line Numbernumber1number2number3aba>bRETURNOUTPUT
97
1012
11712
1712

Share Button