Convert the following infix expression into its equivalent post fix expression…
2014
Convert the following infix expression into its equivalent post fix expression
(A + B^ D) / (E – F) + G
- A.
ABD^ + EF – / G+
- B.
ABD + ^EF – / G+
- C.
ABD + ^EF / – G+
- D.
ABD^ + EF / – G+
Attempted by 736 students.
Show answer & explanation
Correct answer: A
Final postfix expression: A B D ^ + E F - / G +
Handle the exponent first: B^D becomes B D ^ because exponentiation has highest precedence and appears immediately after its operands in postfix.
Form the numerator A + (B^D): this becomes A B D ^ +.
Form the denominator E - F: this becomes E F -.
Apply the division to the two results: A B D ^ + E F - /.
Finally add G to the result: A B D ^ + E F - / G + which is the final postfix expression.
Note: Operator precedence and associativity determine this order: exponentiation has highest precedence and is right-associative, while multiplication/division come next and addition/subtraction last. In postfix, each operator appears after its operands.