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

Evaluate the postfix expression: 1 1 - 5 9 + 9 * +

  1. A. 122
  2. B. -126
  3. C. 126
  4. D. 101

Correct answer: C. 126

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

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

Exams that ask this topic