You are to modify the ADT interface and implementation by writing a recursive method named recursiveMax() that returns the largest integer in a List of integers.
The approach you can take is as follows:
If you divide the List ADT contents into two pieces— halves, for example—and find the largest integer in each of the two pieces, the largest integer in the entire List ADT will be the larger of these two integers. Since you will be searching a portion of the List ADT—for example, the elements [first] through [last]—these will be convenient to use as method parameters. In total, you should have 3 method parameters: the array of the List ADT and two array indices, first and last.
As an example of using this recursive method approach, look at the following method that recursively displays an array:
public static void displayArray(int array[], int first, int last) {
if (first == last)
System.out.print(array[first] + "");
else {
int mid = (first + last) / 2;
displayArray(array, first, mid);
displayArray(array, mid + 1, last);
}// end if-else
}// end displayArray
Notice how mid is used to divide the array contents into two pieces. Notice also how the base case plays a role in deciding what value should be displayed.
Once you have modified the List ADT to have the recursiveMax() method, write a Java Client program that makes a List ADT object, takes integers as input from a user, stores the integers in the List ADT object, and displays the maximum value of the integers using the recursiveMax() method.
The Client program will have a main() method and is the program that is run at the command line. You may give your Client program any name you like. The Client program should perform a loop, ask for input, and display output in the following way (note that the output in bold is what the user inputs):
Input a list of integers: 5 9 101 183 4893
The maximum value found by recursiveMax is: 4893.
Do you want to continue (y/n): y
Input a list of integers: 0 5 9 -48 -7 101 183
The maximum value found by recursiveMax is: 183.
Do you want to continue (y/n): y
Input a list of integers: 14
The maximum value found by recursiveMax is: 14.
Do you want to continue (y/n): y
Input a list of integers:
The maximum value found by recursiveMax is: nothing.
Do you want to continue (y/n): n