Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

complete method in java! public class MaxMin LAB 9: Recursion, Pt. 1 public clas

ID: 3698903 • Letter: C

Question

complete method in java!

public class MaxMin LAB 9: Recursion, Pt. 1 public class Recursion [ public static void main(Strinal.gras) int[] values 19, 12, 13, 14, 17, 18, 16, 14, 11}; int? maxMinResults = maxMin(values, ø, values.length - 1); System.out.println(maxMinResults[0]and " maxMinResults1]); *maxMinO - Return an array containing the minimum and maximum values of the input array *eparam list: an array of ints as input eparam first: the first index of the list (for recursion) *eparam last: the last index of the list (for recursion) it *Identify a base case, and work it out so that the array returns the min and max values. *Then, identify what the method does to recursively arrive at the base case. *@return: an int array, one index is minimum and the other is the maximum value. public static int maxMinCint[l.list..int.first...int.last)

Explanation / Answer

public static int[] maxMin(int[] list, int first, int last) { if(first == last) { return new int[] {list[first], list[first]}; } else { int[] temp = maxMin(list, first+1, last); if(list[first] temp[1]) { temp[1] = list[first]; } return temp; } }