ALGORITHM FOR CONVERTING INFIX TO POSTFIX EXPRESSION

 

1.    infix expression => a + b

        postfix expression => ab*

2.    why to convert infix expression to postfix expression ? 

=>    There are many uses of postfix expression .for eg building expression tree which is quite hectic way by doing it through infix expression.

3.     Following is the algorithm for converting infix to postfix expressionn in simple words =>

        1. scan the infix string from left to right.

        2.if the character is operand then simply print it.

        3.if character is operator then following are the classifications =>

                    1. If there is nothing in stack then simply push operator in stack

                    2. If the top element has less precedence the simply push operator in stack.

                    3.If top element has more precedence then pop the element and print it until top element has                           more precedence.

                    4.If the top element has equal precedence then go with associativity.

                    5.At the end of string pop and print all items.

                        

Comments

Popular posts from this blog

3 MAPPING TECHNIQUES

VIRTUAL MEMORY

ADJACENT MATRIX