Skip to content
Official PYQ · 2015

GATE CS 2015 Set 3 Q12 — Arrays, Stacks and Queues

Explain with AI

The result evaluating the postfix expression 10 5+60 6/∗8−10 \ 5 + 60 \ 6 / * 8 - is 

Choose one option
View worked solution

Answer: C

To evaluate the postfix expression 10  5  +  60  6  /  ∗  8  −10 \; 5 \; + \; 60 \; 6 \; / \; * \; 8 \; -, we use a stack to store the operands and apply operators to the top two elements of the stack:

  1. Scan 10, 5: Push both onto the stack.
    Stack: [10, 5]
  2. Scan +: Pop 5 and 10. Compute 10+5=1510 + 5 = 15. Push 15.
    Stack: [15]
  3. Scan 60, 6: Push both onto the stack.
    Stack: [15, 60, 6]
  4. Scan /: Pop 6 and 60. Compute 60/6=1060 / 6 = 10. Push 10.
    Stack: [15, 10]
  5. Scan *: Pop 10 and 15. Compute 15×10=15015 \times 10 = 150. Push 150.
    Stack: [150]
  6. Scan 8: Push 8 onto the stack.
    Stack: [150, 8]
  7. Scan -: Pop 8 and 150. Compute 150−8=142150 - 8 = 142. Push 142.
    Stack: [142]

Thus, the final evaluated result is 142, which corresponds to option C.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Arrays, Stacks and Queues questions