show the detailed contents of stacks to evaluate the given postfix expression
( 1 2 3 + * 3 2 1 - + * )
Answers
Answered by
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
Computer Science,
16 hours ago
Computer Science,
16 hours ago
English,
16 hours ago
Math,
1 day ago
Math,
1 day ago
English,
8 months ago
English,
8 months ago