The reverse Polish notation of the following infix expression [A*{B+C*(D+E)}]…

2021

The reverse Polish notation of the following infix expression [A*{B+C*(D+E)}] / {F*(G+H)} is__________.

  1. A.

    ABCDE+*+*FGH+*/

  2. B.

    ABCDE*++*FGH+*/

  3. C.

    ABCDE+*+*FGH*+/

  4. D.

    ABCDE+**+FGH+*/

Attempted by 455 students.

Show answer & explanation

Correct answer: A

Method:

  1. Evaluate the innermost parentheses first: D+E becomes DE+.

  2. Multiply C by the result: C*(D+E) becomes CDE+*.

  3. Add B to that result: B + (C*(D+E)) becomes BCDE+*+.

  4. Multiply A by that sum: A * (B + C*(D+E)) becomes ABCDE+*+*.

  5. For the denominator, add G and H: G+H becomes GH+.

  6. Multiply F by that sum: F*(G+H) becomes FGH+*.

Finally, divide the numerator postfix by the denominator postfix by concatenation with the division operator:

Numerator: ABCDE+*+*

Denominator: FGH+*

Postfix (reverse Polish notation): ABCDE+*+*FGH+*/

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

Explore the full course: Coding For Placement