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

Evaluate the postfix expression: 5 9 + 4 * 2 +

  1. A. 59
  2. B. 57
  3. C. -58
  4. D. 58

Correct answer: D. 58

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 58.

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

Exams that ask this topic