Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 import java.util.Arrays; 2 ? public class Labs{ //part a) // base case 1 return a[e]; 4 public static int maximum(intl] a)t if(a.length ## 1)
1 import java.util.Arrays; 2 ? public class Labs{ //part a) // base case 1 return a[e]; 4 public static int maximum(intl] a)t if(a.length ## 1) // base case 2 9 if (a.length2) if(a[a.length-1]a[a.length-2]) return ala.length-2]; return a[a.length-1]; // comparing the last 2 and putting the greater number in last but one in the array a[a.length-2]a[a.length-1]; return maximum(Arrays.copyOfRange(a, , a.length-1)); // part b) int resulta[ej; else 6' ?f(a[a.length-1] > a[a.length-2]){ 2 public static int minimum (int[] a)f 4 for (int i-1; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started