Sorting algorithms

EasyMediumHard
12345678910111213141516171819202122
Question 17
Easy

An atmospheric scientist is writing a bubble sort algorithm to sort barometric pressure readings (in hPa) in ascending order.

Figure 1

1  CONSTANT N ← 4
2  readings ← [1013, 1008, 1015, 998]
3  FOR i ← 0 TO N - 2
4      FOR j ← 0 TO N - i - 2
5          IF readings[j] > readings[j+1] THEN
6              temp ← readings[j]
7              readings[j] ← readings[j+1]
8              readings[j+1] ← temp
9          ENDIF
10     ENDFOR
11 ENDFOR

Identify which of the options contains the false statement about the algorithm in Figure 1.

The algorithm sorts the array in descending order.

The total number of key comparisons performed during execution is 666.

The total number of swap operations executed during execution is 444.

The algorithm utilizes nested definite iteration.

Sorting algorithms Questions

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