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

Evaluate the postfix expression: 1 1 - 5 - 5 -

  1. A. -9
  2. B. -10
  3. C. -11
  4. D. 10

Correct answer: B. -10

Scan left to right with a stack: push operands, and on an operator pop b then a and push a op b, preserving operand order (important for - and /). Result -10.

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

Exams that ask this topic