Computer Science, asked by kissmyassthama4114, 10 months ago

Evaluate the following Postfix expression :
4,10,5,+,*,15,3,/,-

Answers

Answered by hukam0685
29
Solution: To evaluate the post fix expression,always keep in mind some working rules of evaluation

1) While reading the expression from left to right, push the element one by one in the stack, if it is an operand.

2)Pop the two operands from the stack, if the element is an operator and then evaluate it.

3) Now push back the result of the evaluation. Now,Repeat it till the end of the expression.

Here given expression is

4,10,5,+,*,15,3,/,-

Enter 4 in stack----4

enter 10 in stack---4,10

enter 5 in stack---4,10,5

Now operator + => 10+5 = 15

Now stack has ---4,15

Now operator * =>4*15 =60

enter 15 in stack----60,15

enter 3 in stack---60,15,3

Now operator /=> 15 /3= 5

Now stack has ---60,5

Now operator - => 60-5= 55

So,expression has value = 55

Hope it helps you.


Answered by dipannitamajee0
2

i am a goran&2()) 9?) jkmmok

ukk328) 3939) 3099/

hjkllooj

Similar questions