Reverse Polish Notation
Aligned to the AQA 7517 specification
- Level
- Intermediate
- Reading time
- 6 min
- Published
- 13 June 2026
- Updated
- 1 July 2026
On this page
Key takeaways
- Reverse Polish Notation (RPN), also called postfix, places operators after their operands, so infix `3 + 4` becomes `3 4 +`.
- RPN requires no brackets because operator precedence and grouping are encoded in the order of operands and operators, so `(3 + 4) * 2` becomes `3 4 + 2 *`.
- RPN is evaluated with a stack: push operands, and for an operator pop two operands, apply it, and push the result; the final remaining value is the answer.
- When evaluating `-` or `/`, the first pop is the right operand and the second pop is the left operand, so `5 3 -` means 5 − 3 = 2.
- Converting infix to RPN can be done by building a binary expression tree and performing a post-order traversal (left, right, node).
Studying this for an exam?
Generate a personalised learning path for this subject. Free to get started.
Key terms
- Infix notation
- Notation that places the operator between its operands, such as `3 + 4`, the familiar everyday form.
- Prefix (Polish) notation
- Notation that places the operator before its operands, such as `+ 3 4`.
- Postfix (Reverse Polish) notation
- Notation that places the operator after its operands, such as `3 4 +`, requiring no brackets.
- Stack
- The data structure used to evaluate RPN: operands are pushed, and operators pop two operands and push the result.
- Expression tree
- A binary tree representing an expression, where a post-order traversal yields the RPN form and precedence is encoded in the structure.
- Post-order traversal
- A tree traversal visiting left subtree, then right subtree, then the node, used to convert an expression tree to RPN.
- Shunting-Yard algorithm
- Dijkstra's 1961 algorithm that converts infix to RPN directly using a stack and an output queue without building a full expression tree.
Frequently asked questions
Read the expression left to right. Push each operand (number) onto the stack. For each operator, pop two operands, apply the operator, and push the result. When the expression ends, the single remaining stack value is the result.
Because the first value popped is the right operand and the second is the left operand. So `5 3 -` means 5 − 3 = 2, not 3 − 5. Getting this backwards loses the mark for `-` and `/`.
Build a binary expression tree respecting operator precedence, then perform a post-order traversal (left, right, node). For example `3 + 4 * 2` gives the tree post-order output `3 4 2 * +`. Pre-order traversal would instead give prefix (Polish) notation.
Generate revision on any topic you study
Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.
Lessons on anything
Structured, level-matched lessons on any topic you study
Practice quizzes
Find out what you actually know before the exam does
Flashcard sets
Lock in key concepts with instant revision cards
Ask Aica
Stuck on something? Get a clear explanation, any time
Graph Traversal: BFS and DFS
Searching Algorithms
Related lessons
9 min
8 min