Using The Postfix Evaluation Algorithm, Find The Final Result For The Following Expression 2 3 2 1 - / 5 3 +
Using The Postfix Evaluation Algorithm, Find The Final Result For The Following Expression 2 3 2 1 - / 5 3 +
expression 2 3 * 2 1 - / 5 3 * +
Input token Output Stack
2 2
3 23
* T1= 2*3 T1=6 T1
2 T1 2
1 T1 2 1
- T2= 2-1 T2= 1 T1 T2
/ T3= T1/T2 T=6/1 T3=6 T3
5 T3 5
3 T3 5 3
* T4= 5*3 T4=15 T3 T4
+ T5= T3+T4 T5= T5
6+15T5=21
Lets Try
• Convert the following expression from infix to postfix notation:
x+y^(z-p*t)-r/t
• Evaluate postfix result of the previous expression if x=5, y= 1, z=2, p=1
,t=3 , r=12