Cambridge O Level Computer Science 2210 · 7.7 Trace tables

Q60 · 2210/22/M/J/24 Q9

Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8.

Q602210/22/M/J/24original Q9Structured · 7 marks
Question 9 from 2210/22/M/J/24

Worked solution

(a)

Follow the flowchart one box at a time. If List[B] is not greater than List[B + 1], swap them using T and set A to TRUE. At B = 5, go back to the start if A is TRUE. Only values that change are written in the table.

ABList[1]List[2]List[3]List[4]List[5]T
15172059
FALSE1171515
TRUE2201515
TRUE3
TRUE4955
5
FALSE1201717
TRUE2
3
4
5
FALSE1
2
3
4
5

Column A correct [1]

Column B correct [1]

Column T correct [1]

Columns List[1] to List[5] with one error only [1]

Columns List[1] to List[5] all correct [1]

(b)

The algorithm is a bubble sort of the data in the array. [1]

It puts the data into descending order (largest first). [1]

KEY IDEAA flag set when a swap happens repeats the passes until a pass has no swaps, which is a bubble sort.
TOTAL 7 marks

Official mark scheme

Mark scheme for 2210/22/M/J/24 question 9
VIDEO
▶ Topic lesson

A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.