COMP 352- Midterm Exam Guide - Comprehensive Notes for the exam ( 78 pages long!)

437 views78 pages

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents