Skip to content

Course home

Sorting algorithms

Sorting algorithms

EasyMediumHard
12345678910111213141516171819202122
Question 17

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.

A

The algorithm sorts the array in descending order.

B

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

C

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

D

The algorithm utilizes nested definite iteration.

Markscheme

Sorting algorithms Questions

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

52 exam-style questions on AQA GCSE Computer Science Sorting algorithms. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank