Data Structures & AlgorithmsHardGATE CS · TCS NQT · Product Company SDE

Evaluate the postfix expression: 8 8 2 + * 3 1 + 8 + *

  1. A. 1152
  2. B. -960
  3. C. 960
  4. D. 768

Correct answer: C. 960

Scan left to right with a stack: on an operator pop b then a and push a op b (note the order for −). Result 960.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic