Postfix to Infix Conversion

Steps to convert postfix expression to infix

  1. Scan the given postfix expression from left to right character by character.

  2. If the character is an operand, push it into the stack.

  3. But if the character is an operator, pop the top two values from stack.

    Concatenate this operator with these two values (2nd top value+operator+1st top value) to get a new string.

  4. Now push this resulting string back into the stack.

  5. Repeat this process untill the end of postfix expression. Now the value in the stack is the infix expression.

 

 Conversion of Postfix to Infix using Stack

 a b * c + 

 



 

 

No comments:

Post a Comment