levo

Fundamentals of Algorithms

Reverse Polish notation

  • 2 things to know
  • Paper 1
Start revising · £5/month

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.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

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

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

A driver is .
softwarehardwarestorage

Blank Blitz consolidates the facts

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

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

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

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

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.

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.