Worked solution from the Computational thinking and Problem-solving Paper 3 Advanced Theory booklet, Part 1 of 2.
Insert each number by comparing with the nodes from the root. Go left if smaller, right if larger. 6: 6 < 36, 6 < 12, 6 > 3, so right of 3. 15: 15 < 36, 15 > 12, so right of 12. 41: 41 > 36, 41 > 40, so right of 40. 66: 66 > 36, 66 > 40, 66 > 41, so right of 41.
| Node | Left pointer | Right pointer |
|---|---|---|
| 36 | arrow to 12 | arrow to 40 |
| 12 | arrow to 3 | arrow to 15 |
| 40 | -1 | arrow to 41 |
| 3 | -1 | arrow to 6 |
| 6 | -1 | -1 |
| 15 | -1 | -1 |
| 41 | -1 | arrow to 66 |
| 66 | -1 | -1 |
Any two new nodes added correctly with correct data and arrows [1]
The other two nodes added correctly, with all arrows starting from the pointer boxes [1]
Correct -1 null pointers added throughout [1]
No entries in the other pointer boxes and all nodes correctly placed and connected [1]
Say what recursion is, then when it stops.
Recursion is a technique where a subroutine (function or procedure) calls itself to solve a problem [1]
It keeps calling itself until the base case (terminating condition) is reached, when no more recursive calls are made [1]
Write one ADT.
Stack [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.