Prefix, Infix, and Postfix Notation
Let
be a binary operation and
,
two expressions
We can write
in
| prefix notation | |
| infix notation | |
| postfix notation | |
Infix is the worst notation: it requires parantheses, the other two do not!
---------
+
x y
---------
+
* z
x y
---------
+
x *
y z
---------
*
x +
y z
---------
+
+ u
+ z
x y
---------
| prefix | + + + x y z u | + x + y + z u |
| infix | ( ( x + y ) + z ) + u | x + (y + (z + u )) |
| postfix | x y + z + u + | x y z u + + + |
---------
+
+ u
+ z
x y
---------
+
x +
y +
z u
---------
Other names:
- prefix = Polish notation (attributed to Jan Lukasiewicz from Poland)
- postfix = Reverse Polish notation (RPN)
Is the sequence of characters in postfix opposite to one in prefix?
Postfix will be of particular interest to us today