Skip to content

Course home

Sorting algorithms

Sorting algorithms

EasyMediumHard
123456789101112131415161718192021222324252627
Question 20

Complete the trace table for the algorithm shown in Figure 1 which sorts a list of three elements in descending order.

Some values have already been entered. You may not need to use all the rows in the table.

Figure 1

1  arr[0] ← 2
2  arr[1] ← 7
3  arr[2] ← 9
4  FOR i ← 0 TO 1
5      FOR j ← 0 TO 1
6          IF arr[j + 1] > arr[j] THEN
7              temp ← arr[j]
8              arr[j] ← arr[j + 1]
9              arr[j + 1] ← temp
10         ENDIF
11     ENDFOR
12 ENDFOR
arrijtemp
[0][1][2]
279
[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