Stack Applications
Stack Applications
Stack Applications
Data Structures & Algorithms
Example of Stacks
INFIX, POSTFIX and PREFIX
– Infix: A+B-C
– Postfix: AB+C-
– Prefix: -+ABC
• ( (AB+)*C-(DE-) ) $ (FG+)
• ( (AB+C*)-(DE-) ) $ (FG+)
• (AB+C*DE--) $ (FG+)
• AB+C*DE- -FG+$
/* symb is an operator */ - 6 5 1 1
$ 7 2 49 49
3 7 2 49 49,3
+ 49 3 52 52
Data Structures & Algorithms
Consider an Example: Q: A + ( B * C - ( D / E ^ F ) * G ) * H