MaxElement Program
Description
This program uses a recursive method to find the largest element in an integer array.Associated Concepts:
Recursion
Algorithm:
main method:
findMax method definition:
Create an array with a number of integer elements.
Call the recursive method findMax() to find the largest element, and pass the array and the starting index as the arguments.
Call the recursive method findMax() to find the largest element, and pass the array and the starting index as the arguments.
findMax method definition:
If the array has only one element, it returns the only element.
Otherwise, the method returns the larger element between the first element and the largest element in the remaining sub-array.
Otherwise, the method returns the larger element between the first element and the largest element in the remaining sub-array.