Complete the trace table for the algorithm shown in Figure 1. Some values have already been entered.
Figure 1
1 list ← [7, 2, 9]
2 changed ← false
3 WHILE changed = false
4 changed ← true
5 i ← 0
6 WHILE i < 2
7 IF list[i+1] < list[i] THEN
8 temp ← list[i]
9 list[i] ← list[i+1]
10 list[i+1] ← temp
11 changed ← false
12 ENDIF
13 i ← i + 1
14 ENDWHILE
15 ENDWHILE
changed | i | temp | list[0] | list[1] | list[2] |
|---|---|---|---|---|---|
false | 7 | 2 | 9 | ||
true | 0 | ||||
| 7 | 2 | 7 | |||