TRACE TABLES
It’s common for you to be asked to complete a trace table in an exam.
An example of a question is shown below with the trace table complete.
Stephen wants to search for an item of data held in an array.
He writes the following algorithm.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
A trace table is shown below which shows the line numbers where a variable has changed.
Work your way through the table below to see if you get the same answers.
Line | List | Target | Counter | Found |
---|---|---|---|---|
1 | [27,16,86,47,87,99] | |||
2 | 47 | |||
3 | FALSE | |||
4 | 0 | |||
6 | TRUE | |||
4 | 1 | |||
8 | FALSE |