Question: 3. Hand write a method that uses a loop to compute the average of all integers from 1 to n. You do not need
3. Hand write a method that uses a loop to compute the average of all integers from 1 to n. You do not need to submit a java file, just directly write the code in this file. First, please do a time analysis, counting each basic operation (such as assignment and ++) as one operation (you need to show the details). Next, write the Big-O notation for the time complexity based on your time analysis. (5 points) Please keep in mind that just using integer division to calculate the average will return a truncated double. public double averageNumber(int n) { //your code goes here }
Step by Step Solution
There are 3 Steps involved in it
Answer Certainly Lets first analyze the time co... View full answer
Get step-by-step solutions from verified subject matter experts
