Tracing & the Purpose of Algorithms Flashcards
All 4 cards in this deck
What is a trace table?
A table with a column for each variable, condition or output being tracked. It records how their values change at each step as the algorithm runs. Not every variable has to be included.
In a trace table, what do the columns hold?
One column for each variable being tracked (or array element, such as
arr[0]), plus a column for a condition or for OUTPUT where needed. Each time a value changes, the new value is written further down its column.True or false? A trace table is used to find syntax errors in a program.
False. It locates logic errors by showing where actual variable values differ from the expected values.
Name two ways to determine the purpose of a simple algorithm.
Trace it with test data in a trace table, and use visual inspection: read the code to see what it inputs, how it changes the variables and what it outputs.