Trace table

11.5.1.4 use trace tables to find and verify the correctness of an algorithm

Trace table

What can we use to check the correctness of an algorithm? 

If we have difficulty finding errors in the program, then we can use the trace table.

Definition

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 purpose of a trace table:

  • Trace table is used to find the value of variables at each step in an algorithm / program.
  • It may be used when debugging a program.
  • The manually calculated value at each stage of the program is compared with that actually set in the program.
  • It may be used when designing a program by writing an algorithm.
  • A trace table is useful for designing or debugging a loop structure.

Create trace table online

Questions:

What is trace tables?
In which type of test we should use trace table?
What type of errors are trace tables used to check? 

 

Exercises:

Ex.1

Ex. 2

Check the following algorithms and complete their trace tables. Go to tasks

Ex. 3

Exam question:

Категория: Debugging | Добавил: bzfar77 (24.09.2020)
Просмотров: 260 | Теги: logic error, programming error, debugging, trace table | Рейтинг: 5.0/1
Всего комментариев: 0
avatar