Data Structures & AlgorithmsHardProduct placement · Amazon/Microsoft

^ is exponentiation (highest precedence, right-associative); * and / come next; + and − are lowest; others are left-associative. What is the prefix (Polish) form of A ^ B + C + (D + E)?

  1. A. ++^ABC+DE
  2. B. ++ED+C^BA
  3. C. +++^ABCDE
  4. D. +AB^C+DE+

Correct answer: A. ++^ABC+DE

Build the expression tree respecting precedence and parentheses, then write it root-first. Reversing the postfix string is a common trap — it also reverses operand order.

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

Exams that ask this topic