Right Click to Search

Friday, July 30, 2024

Conversion of Infix to Postfix Expression [ Manual Method ]


Conversion of an Expression : Infix to Postfix Manual Method
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
= (A + X ) * D + E    [X = BC^]
Step 2 :
  • 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
= Y * D + E    [Y = AX+]
Step 3 :
  • 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
= Z + E    [Z = YD*]
Step 4 :
  • 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] 

Stumble
Delicious
Technorati
Twitter
Facebook

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

 

Learn C Programming Copyright © 2010 LKart Theme is Designed by Lasantha, Free Blogger Templates