Question : Convert Following Expression Into Postfix ??
(A + B ^ C ) * D + E
Step 1 :
- Expression Wrapped in Round Bracket Should be Evaluated Firstly.
- Again Bracket Contain Two Operators - Addition(+) and Raise to(^) .
- Out of these two '^' Operator has Higher Priority.
- So "B^C" should be Evaluated First
(A + B ^ C ) * D + E = (A + B C ^ ) * D + E [B^C Converted Into BC^]
- Now [ B C ^ ] is Converted Expression So Consider it as X
Step 2 := (A + X ) * D + E [X = BC^]
- Evaluate A + X
(A + X ) * D + E = (A X + ) * D + E [A+X Converted Into AX+]
- Now [ A X + ] is Converted Expression So Consider it as Y
Step 3 := Y * D + E [Y = AX+]
- Evaluate Y * D
Y * D + E = Y D * + E [Y*D Converted Into YD*]
- Now [Y D * ] is Converted Expression So Consider it as Z
Step 4 := Z + E [Z = YD*]
- Evaluate Z + E
Z + E = Z E + [Z+E Converted Into ZE+]
Final Postfix Expression :
= Z E + = Y D * E + [Put Value of Z] = A X + D * E + [Put Value of Y] = A B C ^ + D * E + [Put Value of X]
0 Comments:
Post a Comment
Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email