Question: The function should look like the one declared below: [ min _ dist, index _ p 1 , index _ p 2 ] = TnC

The function should look like the one declared below:[min_dist, index_p1, index_p2]= TnC_closest_pair_1D (P)// P is an array of one-dimensional points// index_p1, index_p2 are the index numbers of two closest points // min_dist is the distance between P[index_p1] and P[index_p2]You will use Transform and Conquer approach for this, i.e., You will pre-sort the points before applying your algorithm.Paste your code below.Exercise 2: Run your code on the following input:P =[3,2,3.3,6,7,12,3.9,1,9,18,8,56];NOTE: This input is just an example. You will get different values in the actual lab. Write the output of your code below:Exercise 3:Compare the efficiency of your algorithm with the brute force using following empirical approach:n Implement the brute force algorithm to find the minimum distance between any two points n Implement the transform and conquer algorithm to do the same (Exercise 1 above)n Run above two codes on randomly generated different numbers of input points (forexample,10 points, 20 points, 100 points, 1000 points, 5000 points) and note down the execution times. Make sure that in each trial you generate a random input and then run both codes on that same input.n Plot the times taken by both algorithms as function of the input size, on the same plot. n Explain the plot (which algorithm is faster and why?). By java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!