Application of stack infix to postfix which follows last in first out and it is a linear data structure. Using C++ programming language
Algorithm
(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.
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
Comments