levo

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.

Your recallNot started
Key term

What is Reverse Polish notation?

Evaluation

Why is Reverse Polish notation used?

Questions from this subtopic

Each one with the model answer underneath.

  1. 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. 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. 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. 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. 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. 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.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

A driver is .
softwarehardwarestorage

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

AThe integer 5 is 0101.
B0.75 is 1/2 + 1/4.
CThe fraction bits are 1100.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

Head means the first single element of a non-empty list.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Fundamentals of Algorithms, on a schedule.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.