Cambridge A2 Level Computer Science 9618 · 16.2 Translation Software

Q15 · 9618/31/M/J/21 Q4

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

Q159618/31/M/J/21original Q4Structured · 8 marks
Question 4 from 9618/31/M/J/21

Worked solution

(a)(i)

Write any two of these:

RPN is an unambiguous way of writing an expression [1]

It is read from left to right [1]

It needs no brackets

It needs no rules of precedence (no BODMAS)

Only two of these points can score (2 marks).

(a)(ii)

Name the structure, then give a reason:

A stack [1]

Operands are pushed on, and when an operator is read the top two are popped in the reverse order to how they were pushed [1]

A binary tree also scores for the structure, with the reason that tree traversal lets both infix and postfix be evaluated.

(b)

Do the brackets first: (a – b) gives a b –, (a + c) gives a c +. Multiply them, then divide by 7.

Write: a b - a c + * 7 / [1]

(c)

Work along the RPN, joining the last two items with each operator: a b / gives a / b; then * 4; then a b + gives (a + b); then the final – joins them.

Write: a / b * 4 - (a + b) [1]

(d)

Rewrite the RPN as infix and put in the values.

Correct structure: (a + b) / (c / d) [1]

Correct substitution: (17 + 3) / (48 / 12) [1]

= 20 / 4 = 5

KEY IDEARPN needs no brackets or precedence rules because the order of the operators gives the order of working, and a stack evaluates it.
TOTAL 8 marks

Official mark scheme

Mark scheme for 9618/31/M/J/21 question 4
VIDEO
▶ Topic lesson

A lesson on this topic · by Craig'n'Dave. 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.