Sorting algorithms

EasyMediumHard
12345678910111213141516171819202122
Question 10
Easy

Figure 1 shows a sorting algorithm written in pseudocode.

1  items ← [9, 3, 7, 2]
2  n ← 4
3  swapped ← true
4  WHILE swapped = true
5      swapped ← false
6      FOR j ← 0 TO n - 2
7          IF items[j] > items[j + 1] THEN
8              temp ← items[j]
9              items[j] ← items[j + 1]
10             items[j + 1] ← temp
11             swapped ← true
12         ENDIF
13     ENDFOR
14 ENDWHILE

State one advantage of the merge sort algorithm compared to the sorting algorithm shown in Figure 1.

[1]

Sorting algorithms Questions

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