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

Evaluate the postfix expression: 4 3 * 7 + 1 -

  1. A. -18
  2. B. 17
  3. C. 18
  4. D. 19

Correct answer: C. 18

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

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

Exams that ask this topic