9618/32/O/N/25 question 8: worked solution (October/November 2025, paper 32)

Show as plain text

Cambridge A2 Level Computer Science 9618 · 16.2 Translation Software Worked solution from the System Software Paper 3 Advanced Theory booklet, Part 2 of 2. Q39 9618/32/O/N/25 original Q8 Structured · 8 marks Worked solution (a) Write: to improve the code so that it uses minimum resources , for example less memory, less storage or less CPU time. [1] (b) Rebuild the expression by reading the RPN left to right, using a stack. a b - gives (a - b), then c + gives (a - b + c). [1] c a - gives (c - a), and * multiplies the two results: (a - b + c) * (c - a). [1] d / divides that by d. [1] Write: (a - b + c) * (c - a) / d (c) Push each value. An operator takes the top two items, works out the answer and pushes it back. a = 3, b = 16, c = 9, d = 6. Step Item read Stack (bottom → top) 1 c 9 2 a 9, 3 3 / 3 4 b 3, 16 5 d 3, 16, 6 6 - 3, 10 7 * 30 8 b 30, 16 9 + 46 c, a pushed, then / gives 3: stack 9 → 9, 3 → 3 [1] b, d pushed, then - gives 10: stack 3, 16 → 3, 16, 6 → 3, 10 [1] * gives 30: stack 30 [1] b pushed, then + gives the final answer: stack 30, 16 → 46 [1] KEY IDEA In RPN an operator uses the top two items on the stack and pushes its answer back. TOTAL 8 marks Official mark scheme VIDEO ▶ Starts at Q8 (1:06:00) Starts at Q8 (1:06:00) · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.