The Reverse Polish Notation (RPN) expression: ab*2/cd/* is to be evaluated where a = 20, b = 3, c = 10 and d = 5.
- (a)Show the changing contents of the following stack as the RPN expression is evaluated. [Figure X.X][4]
- (b)Explain how an expression stored in RPN can be evaluated.[3]
This question uses a diagram from the original paper, which isn't shown here. Open the full paper from the past papers archive to see it.
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2023). The mark or mark type is shown in brackets.
- [1] One mark per ring (Max 4). (Expected intermediate stack contents showing: [20], [20,3], [60], [60,2], [30], [30,10], [30,10,5], [30,2], [60])
- [1] The (RPN) expression is read from left to right, one item at a time
- [1] Each element is checked to see if it as operator or a value
- [1] Values are pushed onto a stack until an operator is found
- [1] The operator is applied to the last two values on the stack and the result is pushed back onto the stack
- [1] This repeats until a single value remains, which is the solution.
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →