Data Structures & AlgorithmsVery hardTCS NQT · Infosys

Evaluate the postfix expression 2 3 1 * + 9 -. What is the result?

  1. A. -3
  2. B. -4
  3. C. -2
  4. D. 0

Correct answer: B. -4

3 * 1 = 3, then 2 + 3 = 5, and 5 - 9 = -4. Reversing the subtraction operands gives +4, which is the trap.

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

Exams that ask this topic