Computer Science, asked by sakshi373171, 4 months ago

evaluate the following post fix expression. 50,5,/,5,1 ,*,5,-,+​

Answers

Answered by surajgawade29092001
0

Answer:15

Explanation:

Answered by dreamrob
0

Answer:

Given postfix expression: 50 , 5 , / , 5 , 1 , * , 5 , - , +

Stack = empty

First character : 50 (​operand) (push to stack)

Stack = 50

Second character : 5 (​operand) (push to stack)

Stack = 50 , 5

Third character : / (operator) (pop top two operands, solve and push back to stack)

Stack = empty

50 / 5 = 10 (push to stack)

Stack = 10

Fourth character : 5 (​operand) (push to stack)

Stack = 10 , 5

Fifth character : 1 (​operand) (push to stack)

Stack = 10 , 5 , 1

Sixth character : * (operator) (pop top two operands, solve and push back to stack)

Stack = 10

5 * 1 = 5 (push to stack)

Stack = 10 , 5

Seventh character : 5 (​operand) (push to stack)

Stack = 10 , 5 , 5

Eighth character : - (operator) (pop top two operands, solve and push back to stack)

Stack = 10

5 - 5 = 0 (push to stack)

Stack = 10 , 0

Ninth character : + (operator) (pop top two operands, solve and push back to stack)

Stack = empty

10 + 0 = 10 (push to stack)

Stack = 10

So, the final answer is 10.

Similar questions