Sorting algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637
Question 20
Medium

An algorithm is shown in Figure 1.

1  items ← [12, 45, 19, 8]
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

Which of the following contains the false statement about the algorithm in Figure 1?

The algorithm uses nested iteration.

The algorithm sorts the list in descending numerical order.

The algorithm uses only definite iteration.

The algorithm uses selection to decide whether to swap elements.

Sorting algorithms Questions

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