Cambridge A2 Level Computer Science 9618 · 16.2 Translation Software

Q26 · 9618/31/M/J/24 Q5

Worked solution from the System Software Paper 3 Advanced Theory booklet, Part 2 of 2.

Q269618/31/M/J/24original Q5Structured · 9 marks
Question 5 from 9618/31/M/J/24

Worked solution

(a)

Turn each operator into brackets in order.

5 2 + becomes (5 + 2); 9 3 - becomes (9 - 3). [1]

Then / joins them: (5 + 2) / (9 - 3). [1]

Then * 3: ((5 + 2) / (9 - 3)) * 3 [1]

(b)

Do the brackets first, then the operator that joins them.

(7 + 3) becomes 7 3 + [1]

(2 * 8) becomes 2 8 *, then - and 6 /: 7 3 + 2 8 * - 6 / [1]

(c)

a = 17, b = 5, c = 7, d = 3, e = 10.

Item readStack (bottom → top)
a17
b17, 5
-12
c12, 7
d12, 7, 3
+12, 10
*120
e120, 10
/12

17 and 5 pushed, then 12 after - [1]

7 and 3 pushed, then 10 after + [1]

120 after * [1]

10 pushed, then final answer 12 after / [1]

Marks are given for correct stack stages like these.

KEY IDEAConvert RPN by joining the top two items with each operator, and evaluate it using a stack.
TOTAL 9 marks

Official mark scheme

Mark scheme for 9618/31/M/J/24 question 5
VIDEO
▶ Starts at Q5 (30:16)

Starts at Q5 (30:16) · by Pseudocode Pro. 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.