Question: Implement a recursive function that finds the maximum element in an ArrayList. Do not use loops or static variables. You are allowed to destruct the
Implement a recursive function that finds the maximum element in an ArrayList. Do not use loops or static variables. You are allowed to destruct the ArrayList.
static Float maxElem(ArrayList elems) { /* YOUR CODE */ }
You can use the following Array member functions: // members of ArrayList (storing objects of type E) E remove(int index) // removes elements at index int size() // returns the number of elements in the list boolean isEmpty() // returns whether the list is empty E get(int index) // returns the element at index boolean add(E e) // adds e to the list, and always returns true
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
