Data Structures & AlgorithmsHardTCS NQT · Infosys

Evaluate the postfix (reverse Polish) expression 5 1 2 + 4 * + 3 -. What is the value?

  1. A. 15
  2. B. 14
  3. C. 12
  4. D. 18

Correct answer: B. 14

Operands are pushed on a stack and each operator pops the top two, with the second popped value as the left operand. Reversing the order of the operands for subtraction gives the wrong sign.

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

Exams that ask this topic