Question: MergeSort uses divide and conquer to sort a vector (array). The same technique can be used to find the distance between the closest pair

MergeSort uses divide and conquer to sort a vector (array). The same

 

MergeSort uses divide and conquer to sort a vector (array). The same technique can be used to find the distance between the closest pair of points in a vector of points in a plane: findclosest(2DPoint[] array) { } mergesort_by_x_coord(array) return helper(array) helper(2DPoint[] array) { left, right split (array, array. length / 2) split x = (max_x_coord (left) + min_x_coord (right) ) / 2 closest left closest right findclosest (left) find closest (right) m = min(closest_left, closest_right) Points2D[] tmp = array.copy_subset (split_x-m

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The time complexity of this algorithm is On log2 n The mergesortbyxcoord function has a time compl... View full answer

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 Programming Questions!