Chapter 8 Trace Tables

8.1 What is a Trace Table?

A trace table is a technique used to test algorithms or computer programs/scripts for logic errors that occur while the algorithm or program/script executes.

The trace table simulates the flow of execution. Statements are executed step by step, and the values of variables change as an assignment statement is executed.

Trace tables are useful for educational purposes. They are typically employed by novice programmers to help them visualize how a particular algorithm or program works and to assist them in detecting logic errors.

A typical trace table is shown here.

Step Statement Notes $variable1 $variable2 $variable3
1          
2          
         

Let's see a trace table in action! ...

Get PHP and Algorithmic Thinking for the Complete Beginner now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.