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

Evaluate the postfix expression: 2 1 * 2 - 6 +

  1. A. 7
  2. B. 9
  3. C. 6
  4. D. -6

Correct answer: C. 6

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

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

Exams that ask this topic