COMP 352- Midterm Exam Guide - Comprehensive Notes for the exam ( 78 pages long!)
Document Summary
// this method returns the number of elements in. // a non-empty array that are greater than the. // @param a - a non-empty array of double values. // @param mean - the mean of the values in the. // array (sum of elements / array length) // @return the number of elements that are greater. // than mean public static int abovemeancount(double[] a, double mean) int n = a. length, count = 0; for(int i = 0; i < n; i++) return count; if(a[i] > mean) count++; Now you can check that in binary recursive approach, time taken by second last and last iteration is very high almost 639 and 7039 milliseconds or 1 and 7 seconds . And loop run for max 50 if we run the same loop for 100 then definitely this time will reach to minute which is very high time consumption.