Trace Tables Flashcards

1
Q

Definition of a trace table -

A

Used to simulate the execution of an algorithm, looking for any logic errors that may be hiding in the algorithm.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Logic errors (definition and examples)

A

A logic error is an error that causes the program to work incorrectly.

Common logic errors might be that we have used the wrong Boolean operator (e.g. AND instead of OR) or the wrong comparison operator (e.g. < instead of >).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Trace table for the following algorithm:

number = int(input(“Please input a number: “))
count = 1
result = 1
for count to number:
result = result + count
print(result)
next count

A

FOR THE FIRST CYCLE
- assign each variable a column which are count, result, number,
- assign the output a column
- User inputs 3 so number = 3
- count = 1
- result = 1
- change result from 1 to 2 as result = result + count
- output = 2 as result = 2

  • Keep repeating the loop until it doesn’t need to repeat (until number = count)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly