Question: Assume an infix expression can only contain five operators, * / % + -, left and right parenthesis, and variables or numbers (can be negative).

Assume an infix expression can only contain five operators, * / % + -, left and right parenthesis, and variables or numbers (can be negative). Operators and operands are separated by white spaces, and there is no space between negative sign and its following operand. Implement this java method, public static String infixToPostFix(String infixExp), using the following algorithm: Use a stack to store operators. If an item is popped from the stack, it will be appended to the output if it is not a parenthesis. When an operand is read, append it to the output When a right parenthesis is read, pop entries from the stack until a (corresponding) left parenthesis is reached, which is then popped but not appended to the output. If any other symbol is read, pop entries from the stack until an entry of lower priority is reached, then the new operator is pushed on the to stack. Left parenthesis has the highest priority. If it is the end of input, pop entries from the stack until it is empty.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!