Data Structures & AlgorithmsModerateCognizant · Capgemini pattern

What is the prefix (Polish) form of (A + B) * (C − D)?

  1. A. * + A B − C D
  2. B. * A B + − C D
  3. C. A B + C D − *
  4. D. + A B * − C D

Correct answer: A. * + A B − C D

The last operator applied is *, so it comes first, followed by the prefix forms of its two operands: + A B and − C D. A B + C D − * is the postfix form.

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

Exams that ask this topic