Skip to content

Course home

Sorting algorithms

Sorting algorithms

EasyMediumHard
123456789101112131415161718192021222324252627
Question 21

A marine research drone records underwater depth measurements at three specific coordinates. The initial depth readings are stored in an array depth of size 3 as follows: depth[0] = 4, depth[1] = 11, and depth[2] = 15 (in meters).

An algorithm is run to sort these depths in descending order:

1  depth[0] ← 4
2  depth[1] ← 11
3  depth[2] ← 15
4  FOR i ← 0 TO 1
5      FOR j ← 0 TO 1
6          IF depth[j] < depth[j + 1] THEN
7              temp ← depth[j]
8              depth[j] ← depth[j + 1]
9              depth[j + 1] ← temp
10         ENDIF
11     ENDFOR
12 ENDFOR

Complete the trace table for this algorithm. Some values have already been entered. You may not need to use all the rows in the table.

depth[0]depth[1]depth[2]ijtemp
41115
[6]
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