Application of stack infix to postfix which follows last in first out and it is a linear data structure. Using C++ programming language

**Algorithm**

- Push ‘(‘ to the stack.
- Scan the infix expression from left to right and repeat steps 3 to 6 for each element until the stack is empty.
- If an operand is encountered, add it to the postfix expression.
- If a left parenthesis is encountered, then push it into the stack.
- If an operator is encountered, then:

(a) Repeatedly pop all the operators from the stack which have the same or higher precedence than the operator that is being encountered and add it to the postfix expression.

(b) Push the operator to the stack. If the right parenthesis is encountered, then:

6.

(a) Repeatedly pop operators from the stack and add them to the postfix expression until a left parenthesis is encountered.

(b) Remove the left parenthesis and pop it.

- Stop.

For Example:

It follows stack evaluation the pop operation is done and the element is deleted from the top of the stack

Likewise the example a follows

The expression is (a*b+c)

Converted Expression is ab*c+

Submitted by Srivenurajulu G (Srivenurajulu)

Download packets of source code on Coders Packet