Question: Determine the growth function and time complexity (in Big-Oh notation) of the findMin method of the code below. Please show your work by annotating the

Determine the growth function and time complexity (in Big-Oh notation) of the findMin method of the code below. Please show your work by annotating the code. //Test.java public class Test { // required method. it takes a generic array of Comparable, that includes // any objects implementing Comparable interface (Integer, String etc.) and // returns the object with minimum value. // below line is needed to remove compiler warnings about unsafe type // casting. @SuppressWarnings("unchecked") public static  T findMin(Comparable array[]) { // initializing min to null T min = null; // looping through the array for (int i = 0; i < array.length; i++) { // if this is first element or if this element is smalller than min, // setting it as new min if (min == null || array[i].compareTo(min) < 0) { min = (T) array[i]; } } // returning min return min; } // for testing... public static void main(String[] args) { // creating an integer array, displaying min value Integer arr1[] = { 10, 8, 13, 42, 27, -36, 49 }; System.out.println(findMin(arr1)); // creating an String array, displaying min value (alphabetically) String arr2[] = { "oliver", "johnny", "abe", "wade", "kate" }; System.out.println(findMin(arr2)); // abe } }

/*OUTPUT*/

-36 abe

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!