Given an expression (A+B∗D)/(E−F)+G A. The prefix notation is +/+A∗DB−EFG B.…

2022

Given an expression

(A+B∗D)/(E−F)+G

A. The prefix notation is +/+A∗DB−EFG

B. The prefix expression is the reverse of the postfix expression

C. The order of operands in infix expression and postfix expression are the same.

D. The order of operands in infix expression, prefix expression and postfix expression are the same.

Choose the most appropriate answer from the options given below:

  1. A.

    A, C and D Only

  2. B.

    C and D Only

  3. C.

    A and B Only

  4. D.

    A and D Only

Attempted by 598 students.

Show answer & explanation

Correct answer: B

Answer: The only true statements are the ones that say the operand order is preserved (infix vs postfix, and infix vs prefix vs postfix).

Workout (convert and compare):

  • Infix: (A + B * D) / (E - F) + G

  • Prefix: + / + A * B D - E F G

  • Postfix: A B D * + E F - / G +

Compare operand order:

  • Operands left-to-right in infix: A, B, D, E, F, G

  • Operands left-to-right in postfix: A, B, D, E, F, G (same as infix)

  • Operands left-to-right in prefix: A, B, D, E, F, G (same as infix and postfix)

Why the other statements are false:

  • A statement that gives a specific incorrect prefix notation is false because it misorders the multiplication operands (it uses D before B). The correct prefix uses B before D.

  • The claim that a prefix expression is simply the reverse of the postfix expression is not generally true; you cannot obtain prefix by merely reversing postfix tokens.

Conclusion: The true statements are the ones about operand order (infix vs postfix, and infix vs prefix vs postfix). Therefore the correct choice is the one that selects those two statements.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Coding For Placement