Print the operands as they arrive.

If stack is empty or contains a left parentheses on top, push the incoming operator onto the stack.

If incoming symbol is '(', push it onto stack.

If incoming symbol is ')', pop the stack and print the operators until the left parentheses is found.

If the incoming symbol has higher precedence than the top of the stack, push it on the stack.

If the incoming symbol has lower precedence than the top of the stack, pop and print the top. Then test the incoming operator against the new top of the stack.

If the incoming operator has equal precedence with the top of the operator , use

**Associativity**rule.If associativity is Left -> Right (^), then pop and print the top of the stack and then push the incoming operator.

If the associativity is Right -> Left (+,-,*,/) , then push the incoming operator.

At the end of the expression, pop and print all operators of stack.

Your conversion should be ready.

Thank You!

## Top comments (0)