Data Structures & AlgorithmsHardWipro · Accenture pattern

^ is exponentiation (highest precedence, right-associative). What is the postfix form of A + B * C ^ D ^ E − F?

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

Correct answer: B. A B C D E ^ ^ * + F −

C ^ D ^ E = C ^ (D ^ E) → C D E ^ ^; times B → B C D E ^ ^ *; then A + that, and − F last because + and − are left-associative. Treating ^ as left-associative gives C D ^ E ^.

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

Exams that ask this topic