AQA A-Level Computer Science 7517
Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation
Fundamentals of Data Representation
Fundamentals of Computer Systems
Fundamentals of Computer Organisation and Architecture
Fundamentals of Communication and Networking
Consequences of Uses of Computing
Systematic Approach to Problem Solving
Fundamentals of Databases
Big Data
Fundamentals of Algorithms
Reverse Polish notation
- 2 things to know
- Paper 1
Overview
Recall questions on converting between infix and postfix, evaluating a postfix expression with a stack, and why the notation needs no brackets.
What you need to know
Answer each one before you reveal it.
Why is Reverse Polish notation used?
Questions from this subtopic
Each one with the model answer underneath.
- 1
What is Reverse Polish notation?
Model answer
A way of writing an expression in which each operator is written after the operands it applies to, rather than between them. It is also called postfix notation. For example the infix expression 3 + 4 is written 3 4 + in Reverse Polish.
- 2
What is infix notation?
Model answer
The ordinary way of writing an expression, with each binary operator placed between its two operands, as in 3 + 4. Because the order of evaluation is not shown by the layout, infix notation needs rules of operator precedence and brackets to say which operation is performed first.
- 3
Convert (3 + 4) * 5 to Reverse Polish notation.
Model answer
3 4 + 5 *. The bracketed subexpression 3 + 4 becomes 3 4 +, and that result is then multiplied by 5, so the operands 3 4 + and 5 are followed by the operator *.
- 4
Convert 5 + 3 * 2 to Reverse Polish notation.
Model answer
5 3 2 * +. Multiplication binds more tightly than addition, so 3 * 2 is evaluated first and becomes 3 2 *; that result is then added to 5, giving 5 3 2 * +.
- 5
Convert (a + b) * (c - d) to Reverse Polish notation.
Model answer
a b + c d - *. Each bracketed subexpression is converted in turn — a + b becomes a b + and c - d becomes c d - — and the operator that joins them, *, is written after both.
- 6
Convert 7 2 3 * - from Reverse Polish notation to infix form and evaluate it.
Model answer
Working left to right, 2 3 * means 2 * 3, and then 7 followed by that result and the operator - means 7 - (2 * 3). The infix form is 7 - 2 * 3, which evaluates to 7 - 6 = 1.
Other ways to work this
The same content, four other ways.
Everything in your subscription
Runs, plus a mode for every other kind of session.
Every question in Fundamentals of Algorithms, on a schedule.
Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.
Or £46 a year, about £3.83 a month. Cancel anytime.