Trace table
A trace table (also known as a trace table ) is a technique used to test algorithms to ensure that logical errors do not occur while the algorithm is processing. The table usually has several columns, each of which shows a variable, and several rows, with each row showing a number entry in the algorithm and the subsequent values of the variable.
Trace tables are typically used in schools and colleges when teaching students to code . They can be an essential tool in explaining to students how a particular algorithm works and how the systematic process that occurs when the algorithm is executed works. They can also be useful for debugging applications and can help the programmer easily see what error is occurring and why it can occur.
example
int i, x = 0;
for (i = 1; i <= 10; i++)
{
x = i * 2;
}
i | x |
---|---|
? | 0 |
1 | 2 |
2 | 4th |
3 | 6th |
4th | 8th |
5 | 10 |
6th | 12 |
7th | 14th |
8th | 16 |
9 | 18th |
10 | 20th |
11 | 20th |
This example shows the systematic process that takes place during the processing of the algorithm. The initial value of x is zero, but i was defined but not assigned a value. Therefore, its initial value is unknown. As the program runs, the values of i and x change line by line, reflecting every instruction in the source code as it executes. Your new values are recorded in the trace table. If i reaches the value 11 due to the i ++ statement in the for definition, the comparison i <= 10 is evaluated as false, which stops the loop. Since the end of the program has been reached, the trace table also ends.
Web links
- comscigate.com
- TalkTalk Webspace is closing soon !! Retrieved December 2, 2019 .
Individual evidence
- ↑ inf school | Case Study - Population Evolution (Fack Concept - Assignment). Retrieved May 7, 2020 .
- ↑ Dr Heinz-Erich Erbs, Otto Stolz: Introduction to programming with PASCAL . Springer-Verlag, 2013, ISBN 978-3-663-12071-1 ( google.com [accessed May 7, 2020]).