Question: 2. The formula for the distance between 2 points (r'y,a) and (T2,y2, 22) 1s given (x2- r1)2 + (y2 - yi)2 (22 21)2. Write a

 2. The formula for the distance between 2 points (r'y,a) and

2. The formula for the distance between 2 points (r'y,a) and (T2,y2, 22) 1s given (x2- r1)2 + (y2 - yi)2 (22 21)2. Write a Python program, in a file called distance.py, to find the distance between all pairs of points in a two-dimensional list such as the following: points - [[4,2,1],[-1,3,5], [6,9,-2], [8,-1,5]] Output the coordinates of the two points that are closest to each other along with the distance between the points. Using insertion sort, output the distances between points in descending order. Your solution should include a function distance (a, b), where a and b are points represented by lists of (x,y, z) coor- dinates (ex. a=[4,2,1]), and a function to implement the insertion sort. Your sorting function should not use any built-in Python functions Sample input/output (for the points list above) Sorted distances: 12.37 11.58 9.85 7.87 6.48 6.40 Closest points were: [4, 2, 1] and [8, -1, 5] with distance-6.40

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