1. STACK Applications Polish Notation
A + B
B
(
Step 1
A
Infix Expression
Postfix Expression
Stack
+
POST Fix
2. Algorithm : Postfix Using Stack
Step1: Insert ‘(‘ in the stack.
Step 2: Move from Left to Right in the Expression
Step 2.a: IF Operand Found
Put it on Expression
Step 2.b: IF Operator Found
Put it on Stack
Step 2.b.1: IF Operator’s precedence is Higher than
the top operator on the stack
Put it on Stack
Step 2.b.1: IF Operator’s precedence is Lower than
the top operator on the stack
Extract all higher precedence operators
from the stack and append them on expression
Step 2.b.1: IF ) found
Remove items on the stack till the ( found and
append them on post fix expression
3. Polish Notation
A + B
B
(
Step 1
A
Infix Expression
Prefix Expression
Stack
+
Pre Fix
Operand 1 Operand 2
B
4. Algorithm : Prefix Using Stack
Step1: Insert ‘(‘ in the stack.
Step 2: Move from Left to Right in the Expression
Step 2.a: IF Operand Found
Put it on Stack
Step 2.b: IF Operator Found
Put it on Head of the Expression
Step 2.b.1: IF ) found
Remove operands from the stack till the ( found
and append them on prefix expression
5. A + B
Infix Notation Prefix Notation
B
Queue
A
+
PREFIX Notation with Queue