Question: Given an unsorted ArrayList of Integer values, write a recursive method called smallestNumber that will find the smallest number within the ArrayList. The approach should
Given an unsorted ArrayList of Integer values, write a recursive method called smallestNumber that will find the smallest number within the ArrayList. The approach should use the fact that the smallest number in a subarray of the ArrayList is equal to the smaller of the first number in the subarray and the smallest number in the remainder of the subarray. The subarray will always contain the last item in the ArrayList. The method will take one parameterthe starting index of the subarray; it will also return the smallest number found. Create and test the smallestNumber method in a driver program given the following array: -3, 5, 1, -9, 8, 16, 10, -4, 5, 2, -1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
