2210/22/M/J/24 question 9: worked solution (May/June 2024, paper 22)
Show as plain textHide plain text
Cambridge O Level Computer Science 2210 · 7.7 Trace tables Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8. Q60 2210/22/M/J/24 original Q9 Structured · 7 marks 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. A B List [1] List [2] List [3] List [4] List [5] T 15 17 20 5 9 FALSE 1 17 15 15 TRUE 2 20 15 15 TRUE 3 TRUE 4 9 5 5 5 FALSE 1 20 17 17 TRUE 2 3 4 5 FALSE 1 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 IDEA A 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 VIDEO ▶ Topic lesson A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.