Conversion of Infix Expression To Postfix Expression Using Stack
Conversion of Infix Expression To Postfix Expression Using Stack
Bengaluru, Karnataka
Computer Science & Engineering
School of Computer Science & Engineering
Prepared by,
Ms. Sridevi S, AP/SoCSE, Ms. Meena Kumari, AP/SoCSE, Ms. Rohini A, AP/SoCSE 1
Basic rules to convert infix expression to postfix expression using stack:
1. When an incoming symbol is an operand, print the operand.
2. When an incoming symbol is operator and has equal precedence than the top of the
stack, then check for Associativity,
(i) If Associativity is L to R, pop the top of stack and check the incoming operator
with the current top of the stack.
(ii) If Associativity is R to L, push the incoming operator to the stack
3. When an incoming symbol is operator and has precedence greater than top of the stack,
push the symbol to the stack.
4. When an incoming symbol is operator and has less precedence than the top of the stack,
pop the top of the stack and check the incoming symbol with top of the stack.
Prepared by,
Ms. Sridevi S, AP/SoCSE, Ms. Meena Kumari, AP/SoCSE, Ms. Rohini A, AP/SoCSE 2