0% found this document useful (0 votes)
18 views

Using The Postfix Evaluation Algorithm, Find The Final Result For The Following Expression 2 3 2 1 - / 5 3 +

The document demonstrates how to evaluate a mathematical expression using postfix notation. It shows the step-by-step evaluation of the expression "2 3 * 2 1 - / 5 3 * +" to get a result of 21. It then provides two additional examples: converting an infix expression to postfix notation, and evaluating a postfix expression with given variable values.

Uploaded by

Bandar Abdallat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Using The Postfix Evaluation Algorithm, Find The Final Result For The Following Expression 2 3 2 1 - / 5 3 +

The document demonstrates how to evaluate a mathematical expression using postfix notation. It shows the step-by-step evaluation of the expression "2 3 * 2 1 - / 5 3 * +" to get a result of 21. It then provides two additional examples: converting an infix expression to postfix notation, and evaluating a postfix expression with given variable values.

Uploaded by

Bandar Abdallat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 2

• Using the postfix evaluation algorithm, find the final result for the following

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+15T5=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

You might also like