Monday, March 4, 2019

INFIX TO POSTFIX CONVERTION

INFIX to POSTFIX conversion has the following steps: 
  1. If the character is an operand place it on to the output.
  2. If the character is an operator, push it onto the Stack. if the stack operator has a higher or equal priority than input operator then pop that operator from the stack and place it onto the output.
  3. If the character is a left parenthesis,push it onto the stack.
  4. If the character is a right parenthesis, pop all the operator from the stack till it encounters left parenthesis, discard both the parenthesis in the output.
                '+' has lower priority 
                '*' has higher priority
EXAMPLE
     
 Convert infix expression ((A/B)+C) to postfix expression.

               

No comments:

Post a Comment