Skip to content

Course home

Sorting algorithms

Sorting algorithms

EasyMediumHard
123
Question 2

Complete the trace table for the algorithm shown in Figure 1.

Figure 1

1  arr ← [5, 8, 2]
2  sorted ← false
3  WHILE sorted = false
4      sorted ← true
5      i ← 0
6      WHILE i < 2
7          IF arr[i+1] < arr[i] THEN
8              t ← arr[i]
9              arr[i] ← arr[i+1]
10             arr[i+1] ← t
11             sorted ← false
12         ENDIF
13         i ← i + 1
14     ENDWHILE
15 ENDWHILE
arr[0]arr[1]arr[2]sortedit
582false
[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