Cambridge A2 Level Computer Science 9618 · 16.2 Translation Software

Q25 · 9618/32/O/N/23 Q6

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

Q259618/32/O/N/23original Q6Structured · 7 marks
Question 6 from 9618/32/O/N/23

Worked solution

(a)

Push values; at an operator pop two, calculate, push the result. a = 20, b = 3, c = 10, d = 5.

Item readStack (bottom → top)
a20
b20, 3
*60
260, 2
/30
c30, 10
d30, 10, 5
/30, 2
*60

20 and 3 pushed, then 60 after * [1]

2 pushed, then 30 after / [1]

10 and 5 pushed, then 2 after / [1]

Final multiplication gives 60 [1]

Marks are given for correct stack stages like these.

(b)

The RPN expression is read from left to right, one item at a time. [1]

Each item is checked: a value is pushed onto the stack until an operator is found. [1]

The operator is applied to the last two values (popped), and the result is pushed back. This repeats until one value is left: the answer. [1]

KEY IDEAPush values and apply each operator to the top two stack items until one value is left.
TOTAL 7 marks

Official mark scheme

Mark scheme for 9618/32/O/N/23 question 6
VIDEO
▶ Whole paper

Video solution of the whole paper · by TEACHING BY SM. 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.