Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

Evaluate the postfix expression "2 3 4 * + 5 -".

  1. A. 19
  2. B. 15
  3. C. 5
  4. D. 9

Correct answer: D. 9

The stack gives 3 * 4 = 12 first, then 2 + 12 = 14, and finally 14 - 5 = 9. Evaluating left to right without multiplication precedence is the common slip.

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

Exams that ask this topic