

Step 7: At last after traversing the whole string if still we are left with any operators we pop them and continue Step 5 until the Operator Stack is empty. Then we push the current operator into the stack. If the condition is true, we pop the operator present at the top and process its operands following Step 5. Step 6: Now if we get an Operator as the current character, we check whether the precedence of current operator is lower than the operator present at top of the stack. Step 5: The process for each operator is : We pop two elements from Postfix or operand Stack we concatenate them in reverse order with its operator and add the result again to Postfix stack for future evaluation until we get the total Postfix expression. For each operator we pop its two operands and process them. Closing Parenthesis, we are going to pop the elements out of Operator Stack until we get the opening '('. Opening Parentheses, we push it into Operator Stack. Step 3: If the character encountered is : '(', i.e. We simply push it into the operand or Postfix stack. Step 2: If the Character at each iteration is a Operand.

If the character is a Open or Close Parentheses. For each character, there are three cases to consider : Step 1: We will iterate throughout the String length. We will take decisions when we encounter Parentheses, Operators and Operands.

The Infix expression will be given as a String input. The Operand stack will contain the resultant Postfix expression after traversing string. We will use two Stacks : One for Operators (Character), One for Operands (String). Check for balanced parentheses in expression java Conversion Algorithm
