Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

could I get a bit of help for #3 I think it\'s just trying to find the closest g

ID: 3714688 • Letter: C

Question

could I get a bit of help for #3 I think it's just trying to find the closest gap between two players. but mainly need help on #4, would if be more efficient if we were to sort the array first let's say by merge sort?
thanks!

Basic Analysis 3. (10 points) Given the following code, what does the function do and what is the Big O complexity o f the following function? You can assume that 'n' is the number how many comparisons it does of the n points. oh points, and that all points are in the range 0 to 100. To determine the complexity, figure out double ClosestPointsr double pointel, int ) double closest 100.0 for int pl o pl pin p2+01/0 (n) for (int p2 0 p2 dO.O ;

Explanation / Answer

Q3. We are finding the minimum difference between any two players

Q4. Yes, We can inprove the efficiency.

a) First Sort the array usign merger Sort: O(nlogn) time

b) traverse the array and keep the minimum difference

closest = abs(points[1] - points[0]);

for(int i=2; i<n ; i++) {

if(closest > abs(points[i] - points[i-1])) {

closest = abs(points[i] - points[i-1]);

}

}