Infix to Postfix Conversion Algorithm


Infix to Postfix conversion
A+B  -> Infix
AB+  -> Postfix
+AB  -> Prefix
Algorithm
Step-1  Initialize the stack
Step-2 Scan the leftmost symbol in the given infix expression and denote is as the current input symbol.
Step-3 Repeat through step-6 while infix expression
Step-4 Remove and output all stack symbols whose precedence values are greater than or equal to the precedence of the current input symbol.
Step-5 Push the current input symbol onto the stack.
Step-6 Scan the leftmost symbol in the infix expression and let it be the current symbol.

Post a Comment

Previous Post Next Post