An automated sensor calibration algorithm sorts temperature readings, recorded as temp_listtemp\_listtemp_list, from three volcanic sectors into ascending order.
The algorithm is represented by the following pseudocode:
1 temp_list ← [8, 2, 5]
2 swapped ← true
3 WHILE swapped = true
4 swapped ← false
5 i ← 0
6 WHILE i < 2
7 IF temp_list[i] > temp_list[i + 1] THEN
8 aux ← temp_list[i]
9 temp_list[i] ← temp_list[i + 1]
10 temp_list[i + 1] ← aux
11 swapped ← true
12 ENDIF
13 i ← i + 1
14 ENDWHILE
15 ENDWHILE
Complete the trace table below to show how the variables and list elements change during the execution of this algorithm.
swapped | i | aux | temp_list[0] | temp_list[1] | temp_list[2] |
|---|---|---|---|---|---|
| true | 8 | 2 | 5 | ||
| false | 0 | ||||
| 8 | 2 | 8 | |||
| true | |||||
| 1 | |||||
| 8 | 5 | 8 | |||
| 2 | |||||