9618/32/M/J/25 question 11: worked solution (May/June 2025, paper 32)

Show as plain text

Cambridge A2 Level Computer Science 9618 · 19.1 Algorithms Worked solution from the Computational thinking and Problem-solving Paper 3 Advanced Theory booklet, Part 1 of 2. Q20 9618/32/M/J/25 original Q11 Structured · 6 marks Worked solution (a) Compare each string with the nodes from the root, in alphabetical order. Go left if earlier, right if later. 0 means a null pointer. Aa: before Pp and before Gg, so left of Gg. Mm: before Pp, after Gg, after Kk, so right of Kk. Ss: after Pp, after Rr, so right of Rr. Xx: after Pp, Rr and Ss, so right of Ss. Node Left pointer Right pointer Pp arrow to Gg arrow to Rr Gg arrow to Aa arrow to Kk Rr 0 arrow to Ss Kk 0 arrow to Mm Aa 0 0 Mm 0 0 Ss 0 arrow to Xx Xx 0 0 Any two new nodes added correctly with correct data [1] The other two nodes added correctly, with all arrows starting from the correct pointer boxes [1] Correct null pointers (0) added throughout [1] No entries in the other pointer boxes and all nodes correctly placed and connected [1] (b) Give the feature, then an example. Feature: recursion is beneficial when a problem naturally breaks down into smaller versions of itself [1] Example: calculating a factorial (or a mathematical series, Fibonacci numbers, compound interest, tree traversal, or evaluating RPN expressions) [1] KEY IDEA Recursion suits problems that split into smaller copies of the same problem; a tree places strings by alphabetical order. TOTAL 6 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by rjmcompsci. Tap the picture to open it on YouTube.