Question: Write a recursive method called maxValue that takes an array of ints and two indexes as arguments and returns the maximum value found between those

Write a recursive method called maxValue that takes an array of ints and two indexes as arguments and returns the maximum value found between those two indexes. Identify your base case and your general case. You may assume that the input array will never be allowed to be null. Use the following method signature:

public static int maxValue(int[] arr, int start, int end) 

HINT: How can you make this problem smaller? If you had a function that gave you the maximum value of the items from start+1 to the end, how could you use that to find the maximum value of the entire array?

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!