Worked solution from the Computational thinking and Problem-solving Paper 3 Advanced Theory booklet, Part 1 of 2.
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]
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]
▶ Topic lesson
A lesson on this topic · by rjmcompsci. 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.