Cambridge A2 Level Computer Science 9618 · 19.2 Recursion

Q26 · 9618/33/M/J/25 Q13

Worked solution from the Computational thinking and Problem-solving Paper 3 Advanced Theory booklet, Part 2 of 2.

Q269618/33/M/J/25original Q13Structured · 4 marks
Question 13 from 9618/33/M/J/25

Worked solution

(a)

Run Delete(1, 15) one call at a time. Nothing changes until Numbers[Index] >= 15. At Index 5, Numbers[5] takes the value of Numbers[6], and each later cell copies the one after it. At Index 8 the value 0 is copied, and at Index 9 the cell is 0, so the calls stop.

IndexTarget[1][2][3][4][5][6][7][8][9][10]
237111517192300
115
2
3
4
517
619
723
80
9

Index (1 to 9) and Target (15) columns correct [1]

Numbers[5] column correct (17) [1]

Numbers[6] and Numbers[7] columns correct (19, 23) [1]

Numbers[8] column correct (0), with no other data added to the other columns [1]

KEY IDEATrace a recursive procedure one call at a time, changing only the cells the code actually writes.
TOTAL 4 marks

Official mark scheme

Mark scheme for 9618/33/M/J/25 question 13
VIDEO
▶ Topic lesson

A lesson on this topic · by Craig'n'Dave. 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.