Sorting algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637
Question 8
Medium

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
changeditemplist[0]list[1]list[2]
false729
true0
727
[6]

Sorting algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Sorting algorithms