Question

Consider the algorithm to find the closest pair of points in the plane. Lets say you wanted to generalize the algorithm to f

0 0
Add a comment Improve this question Transcribed image text
Answer #1

We are given an array of n points in the plane, and the problem is to find out the closest pair of points in the array.

Algorithm to find closest pair of points(O(nlogn))
step 1) First we sort all points according to x coordinates.
step 2) Divide set all points in two set of half size.
step 3) Find the smallest distances in both subarrays recursively.
step 4) find the minimum of two smallest distances say it d.
step 5) Create an array points[] that stores all points which are at most d distance away from the middle line dividing the two sets.
step 6) Find the smallest distance in points[].
step 7) Return the minimum of d and the smallest distance calculated in above step 6.

Add a comment
Know the answer?
Add Answer to:
Consider the algorithm to find the closest pair of points in the plane. Let's say you wanted to generalize the algorithm to find the two closest pairs of points in the plane given a set of (unsor...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT