Data Structures & AlgorithmsVery hardTCS NQT · Infosys

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

  1. A. 14
  2. B. 13
  3. C. 16
  4. D. 18

Correct answer: B. 13

Read the tokens from right to left with a stack: operands are pushed, and an operator pops its first operand from the top. Reading left to right without reversing gives a different answer.

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

Exams that ask this topic