Computer Science, asked by kalyanireddychandupa, 1 day ago

show the detailed contents of stacks to evaluate the given postfix expression
( 1 2 3 + * 3 2 1 - + * )​

Answers

Answered by chaitanya0301m8th
2

Explanation:

The given expression be “2 3 1 * + 9 -“. We scan all elements one by one.

1) Scan ‘1’, it’s a number, so push it to stack. Stack contains ‘1’

2) Scan ‘2’, again a number, push it to stack, stack now contains ‘1 2’ (from bottom to top)

3) Scan ‘3’, again a number, push it to stack, stack now contains ‘1 2 3’

4) Scan ‘+’, it’s an operator, pop two operands from stack.

Similar questions