Week 9 Applications of Stack
Week 9 Applications of Stack
STRUCTURES &
ALGORITHMS
Applications of Stack
Infix, Postfix and Prefix
Week 9
INFIX NOTATION
Infix notation is the common arithmetic and logical formula notation, in which operators are
written infix-style between the operands they act on
E.g: A+B
A+B*C
Remember: operators +, - etc.
Operands a, b etc
POSTFIX NOTATION
In postfix notation, the operator comes after the operand.
For example, the infix expression A+B will be written in postfix as AB+
Postfix is also called “Reverse Polish Notation”
PREFIX NOTATION
In prefix notation, the operator comes before the operand.
The infix expression A+B will be written as +AB in its prefix form.
Prefix is also called “Polish Notation.”
INFIX, POSTFIX AND PREFIX
EXPRESSIONS
Infix:
A+B
Prefix:
+ AB
Postfix
AB +