Convert the following arithmetic expression into postfix form: A - B - D * E /…
2018
Convert the following arithmetic expression into postfix form:
A - B - D * E / F + B * C
Answer: D. AB-DE*F / -BC*+ — CONCEPTIn infix-to-postfix conversion, operands are emitted immediately, while operators wait on a stack. An incoming left-associative operator first pops…
- A.
AB-DE / F*-BC*+
- B.
AB-DE* / F-BC*+
- C.
AB-DE*F / -BC+*
- D.
AB-DE*F / -BC*+
Attempted by 631 students.
Show answer & explanation
Correct answer: D
CONCEPT
In infix-to-postfix conversion, operands are emitted immediately, while operators wait on a stack. An incoming left-associative operator first pops operators of higher or equal precedence; multiplication and division outrank addition and subtraction.
APPLICATION
Emit
AandB. When the second subtraction sign arrives, pop the earlier subtraction because both have equal precedence and are left-associative. The output becomesA B -.Emit
DandE, then pop multiplication before division. This createsD E *; after emittingF, division createsD E * F /.When addition arrives, pop the pending division and subtraction. The accumulated output is
A B - D E * F / -; then push addition.Emit
BandC, pop multiplication, and finally pop addition. The completed postfix sequence isA B - D E * F / - B C * +.
CROSS-CHECK
Reading the postfix result back builds (A - B), then (D * E) / F, subtracts the second from the first, and finally adds B * C. This reconstructs A - B - D * E / F + B * C under the standard left-to-right associativity rules.
RESULT
A B - D E * F / - B C * +