First of all, this question must be clear in our mind and i.e. Why do we need to convert infix expression postfix expression?
Conventional notation is called infix notation. The arithmetic operators appears between two operands. Parentheses are required to specify the order of the operations. For example: a + (b * c).
Post fix notation (also, known as reverse Polish notation) eliminates the need for parentheses.
There are no precedence rules to learn, and parenthesis are never needed. Because of this simplicity, some popular hand-held calculators use postfix notation to avoid the complications of multiple sets of parentheses.
The operator is placed directly after the two operands it needs to apply. For example: a b c * +
You got the answer of Why?
Now, it's time to know what?
What is Operand Stack?
When we evaluate a given postfix expression, then we only push the operands into the stack but not any operator. So, the stack used in postfix evaluation called operand stack.
What is Operator Stack?
When we convert an infix notation into postfix notation, then we only push the operators into the stack but not any operand. So, stack used in the conversion from infix to postfix is called operator stack.
Algorithm to convert Infix into Postfix expression using operator stack:
Input is-
if( ‘(‘ )
push in stack
if( ‘)’ )
pop until left parenthesis is popped
if(operator)
1.Lower priority is in input then pop
2.Higher priority is in input then push
3.Same r priority is pop except exponent Operator
if(Operand)
Ignore
After conversion of Infix to postfix, we will evaluate postfix expression using Operand Stack only.