Sorting algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637
Question 24
Medium

Select one option to show which of the following is a false statement about the algorithm in Figure 1.

Figure 1

1  CONSTANT ARRAY_SIZE ← 5
2  arr ← [12, 3, 45, 7, 19]
3  FOR i ← 1 TO ARRAY_SIZE - 1
4      key ← arr[i]
5      j ← i - 1
6      WHILE j >= 0 AND arr[j] > key
7          arr[j + 1] ← arr[j]
8          j ← j - 1
9      ENDWHILE
10     arr[j + 1] ← key
11 ENDFOR

The algorithm utilizes nested iteration, where an indefinite loop is nested within a definite loop.

The named constant ARRAY_SIZE\text{ARRAY\_SIZE}ARRAY_SIZE is used to determine the upper limit of the outer loop.

The algorithm sorts the array in-place, modifying the original array rather than allocating a secondary array.

The pseudocode represents a standard implementation of the selection sort algorithm.

Sorting algorithms Questions

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