Worked solution from the System Software Paper 3 Advanced Theory booklet, Part 2 of 2.
Write each bracket in RPN, then the operator between them goes last: (j + k) is j k +, (j – k) is j k –.
Write: j k + j k - /
j k + [1]
j k - / (the second part and the divide) [1]
Work along m m j k * - *. A number is pushed. An operator pops the top two, works them out and pushes the result. Values: m = 10, j = 3, k = 2. Operators are never put on the stack.
| Item read | Stack (bottom → top) |
|---|---|
| m | 10 |
| m | 10, 10 |
| j | 10, 10, 3 |
| k | 10, 10, 3, 2 |
| * | 10, 10, 6 |
| - | 10, 4 |
| * | 40 |
First four stacks correct (10; 10, 10; 10, 10, 3; 10, 10, 3, 2) [1]
After *: 10, 10, 6 [1]
After -: 10, 4 [1]
After the last *: 40 [1]
Write four of these steps:
Work through the expression from left to right [1]
PUSH each number (10/m, 3/j, 2/k) onto the stack as it is read [1]
When an operator (the first is *) is reached, POP the top two numbers (2 and 3) [1]
Apply the operation to them
PUSH the result back onto the stack [1]
Continue to the end of the expression; the final value left is the answer
Only four points score (4 marks). A purely generic answer without the values scores at most 3.
Write any two uses:
Recursion (storing return addresses and values) [1]
Implementing abstract data types such as linked lists [1]
Procedure calls
Interrupt handling (storing the contents of registers)
Only two score (2 marks).
▶ Whole paper
Video solution of the whole paper · by qiphyedu. 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.