54Hard
0/6

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]

Sorting algorithms Questions

Practise AQA GCSE Computer Science Sorting algorithms with exam-style questions for GCSE Computer Science. 62 questions, matched to the AQA GCSE Computer Science (8525) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

PreviousNext

Sorting algorithms Questions

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