Similar questions 4 more →
Stacks & Queues



Answer & solution
Answer: [10, 7], top = 7 (no official key was published)
Step through it (7 steps)
Read left to right. An operand is pushed; an operator pops the right operand first and then the left, computes left operator right, and pushes the result. The successive stacks are [5], [5,2], [10], [10,3], [10,3,4], [10,7]. The multiplication consumes 5 and 2 to produce 10; the addition consumes only 3 and 4 to produce 7. The earlier 10 remains below the new result. Therefore the requested stack is bottom [10,7] top.