Question: Sample outputs System.out.println(Recursion.indexOf(Hello, lo)); // 3 Stack stack = new Stack (); stack.push(2); stack.push(3); stack.push(4); stack.push(55); stack.push(6); stack.push(17); stack.push(8); System.out.println(Recursion.removeEvenNumbers(stack, 2)); // 2 System.out.println(stack); //

 Sample outputs System.out.println(Recursion.indexOf("Hello", "lo")); // 3 Stack stack = new Stack();

Sample outputs

System.out.println(Recursion.indexOf("Hello", "lo")); // 3 Stack stack = new Stack(); stack.push(2); stack.push(3); stack.push(4); stack.push(55); stack.push(6); stack.push(17); stack.push(8); System.out.println(Recursion.removeEvenNumbers(stack, 2)); // 2 System.out.println(stack); // [2, 3, 4, 55, 17] System.out.println(Recursion.evenDigits(-1364035)); // 640 String expr = "(((1+2)*(3+1))+(1*(2+2)))"; Queue q = new LinkedList(); for (char ch: expr.toCharArray()) { q.add(ch); } System.out.println(Recursion.evaluate(q)); // 16 System.out.println(stack); // [2, 3, 4, 55, 17] Recursion.repeatStack(stack); System.out.println(stack); // [2, 2, 3, 3, 4, 4, 55, 55, 17, 17] Queue q2 = new LinkedList(); q2.add(34); q2.add(15); q2.add(0); Recursion.doubleElements(q2); System.out.println(q2); [68, 30, 0]

Java code please

/** * Write a recursive function that evaluates a Queue as a mathematical * expression. This queue can have any of the following characters: *{ '(',')', 't', '*'} or any single digit number. Evaluate this expression and * return the result. For example, for the expression: * "(((1+2)+(3+1))+(1+(2+2)))", each of these characters would be in the * q. As you recursively evaluate characters from the expression, you will * remove the characters from the q. After evaluating the above expression, you should return 16. You are guaranteed that there are NO two digit numbers, * and that the expression is well formed (parenthesis match, etc...). Do not use any * loops. Do not use any data structures besides the q passed in as a parameter. * @param a * @return The result of the mathematical expression. */ public static int evaluate (Queue q) {} * /** * Write a recursive function that evaluates a Queue as a mathematical * expression. This queue can have any of the following characters: *{ '(',')', 't', '*'} or any single digit number. Evaluate this expression and * return the result. For example, for the expression: * "(((1+2)+(3+1))+(1+(2+2)))", each of these characters would be in the * q. As you recursively evaluate characters from the expression, you will * remove the characters from the q. After evaluating the above expression, you should return 16. You are guaranteed that there are NO two digit numbers, * and that the expression is well formed (parenthesis match, etc...). Do not use any * loops. Do not use any data structures besides the q passed in as a parameter. * @param a * @return The result of the mathematical expression. */ public static int evaluate (Queue q) {} *

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!