Question: 7. ( 5 points) The following function converts a prefix expression to an infix expression assuming the expression can only contain unsigned integer numbers and

 7. ( 5 points) The following function converts a prefix expression

7. ( 5 points) The following function converts a prefix expression to an infix expression assuming the expression can only contain unsigned integer numbers and " + " and " - " operators. public static String convert(String prefix) | stack s - new AStack: String operandi, operand2, infixi int i= prefix. length -1 : while (i>=0) ( char nextc = prefix.charAt (i); if ( (nextc =="+") (nextc ==+1) operandl =spop(); operand 2=spop(); inf 1x=1(+ operand 1+ nextc + operand 2+"); s.push (infix); i--; I else if (Character. isDigit (nextc)) i int end = i; while (Character. isDigit (prefix.charAt (i)) im; infix = prefix.substring (i+1, end +1); s. push (infix); ? else i; 1 return s.pop (); 1 (a) (2.5 points) Rewrite only the lines of code that need to be changed so that the above function converts a prefix expression to a postfix expression. r (b) (2.5 points) Describe in words what changes are needed on the above given convert () function so that it also finds the value of the converted prefix expression

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!