Skip to content

Course home

Sorting algorithms

Sorting algorithms

EasyMediumHard
12345678910111213141516171819202122
Question 8

A deep-sea research probe records hydrostatic pressure measurements at different depths. The recorded pressure values (in kilopascals, kPa) are stored in an array named pressures.

An algorithm to process these readings is represented by the following pseudo-code:

1  pressures[0] ← 102.4
2  pressures[1] ← 305.1
3  pressures[2] ← 150.8
4  pressures[3] ← 412.3
5  FOR p ← 0 TO 2
6      FOR q ← 0 TO 2
7          IF pressures[q] < pressures[q + 1] THEN
8              temp ← pressures[q]
9              pressures[q] ← pressures[q + 1]
10             pressures[q + 1] ← temp
11         ENDIF
12     ENDFOR
13 ENDFOR

State the purpose of this algorithm.

[1]
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