Reverse Polish notation is a parenthesis-free algebraic notation, known as post-fix notation. We are all familiar with standard algebraic notation (or in-fix notation):
(1 + 2) * 3
< in-fix notation >In RPN, this is expressed:
1 2 + 3
* < post-fix notation >The parentheses are used to avoid ambiguity over the order of operations (often taught as BODMAS in school). For example, the first expression could be confused with the literal expression
1 + (2 * 3)
which would give a different result. Parentheses are not required in post-fix notation. For example, 1 + ( 2 * 3 )
is expressed as:1 2 3 * +