Question: Using the algorithm convertToPostfix given in photo below, create a class in java that will convert each of thefollowing infix expressions to postfix expressions for
Using the algorithm convertToPostfix given in photo below, create a class in javathat will convert each of thefollowing infix expressions to postfix expressions for the test case a.

a.) a * b / (c -d)
s. For si Algorithm convertToPostfix(infix) /Converts an infix expression to an equivalent postfic esxpression e simplicity, all operands in our expression are single-letter variables operatorStack - a new empty stack postfix -a new empty string while Cinfix has characters left to parse) nextCharacter next nonblank character of infix switch (nextCharacter) case variable Append nextCharacter to postfix break case 'A break case .+' : case .-' : case . * , : case .1' : while (loperatorStack.isEmptyO and precedence of nextCharacter precedence of operatorStack.peekO) Append operatorStack. peek() to postfix operatorStack.popO operatorStack.push (nextCharacter) break case operatorStack.push(nextCharacter) break case ')' / / Stack is not empty if infix expression is valid : topoperator operatorStack.popO while (topope rator !" ,(') Append topOperator to postfix topoperator operatorStack.pop break default: break// Ignore unexpected characters while (!operatorStack.isEmptyO) topOperator operatorStack.pop) Append topOperator to postfix return postfix
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
