You are on page 1of 1

Infix_Postfix(E):

Input: E is an expression in Infix notation


Output: Postfix expression (PE)
Data structure: STACK
1. Start
2. Add “(“to the starting of E., and add “)” to the end of E.
3. Scan each symbol in E from left to right and perform the following for each
symbol until last symbol.
1. If (symbol==operand) then
add it to postfix expression-PE.
2. else If (symbol==’(‘) then
push it onto Stack.
3. else If (symbol==’operator‘) then
1. Repeatedly pop from Stack and add to PE each operator (on the
top of Stack) which has the same precedence as or higher
precedence than an operator.
2. Add operator to Stack.
4. else If (symbol==’)‘) then
1. Repeatedly pop from Stack and add to PE each operator (on the
top of Stack) until a left parenthesis is encountered.
2. Remove the left Parenthesis from STACK.
5. End if
4. END.

You might also like