Given n points on the x-axis line (in some arbitrary order), find the closest pa
ID: 3724138 • Letter: G
Question
Given n points on the x-axis line (in some arbitrary order), find the closest pair of points in O(n log n) time. Show that the problem can be solved using sorting. Give a divide and conquer algorithm that does not use sorting. (The advantage of this approach is that it generalizes to points in higher dimensions, e.g., 2 dimensions). (Hint: Partition the points into two subproblems of equal size, recursively solve the subproblems, and efficiently combine them to solve the original problem; exploit the fact that the recursion returns the closest pair in the respective subproblems.)
Explanation / Answer
Given a place S = {p1, p2, ..., pn} of n points in the aircraft find the two points of S whose distance is the least.
Input :
Set of point in a level surface, S = {p1, p2, ..., pn}
Output :
{pX,pY}, anywhere pX and pY are the contiguous points in the plane. or coldness between pX and pY is negligible
2.
To prove :
Proof :
In the closest pair, we divide the plane into two subparts and try to resolve the problem recursively.
Algorithm runs in 3 simple part:
a) split the plane into two parts.
b) find the closest pair in every part. let dl and dr be smallest diatance in each part.
c) unite the two parts and find the return the closest pair.
Let dl be the closest distance in left partition, and dr be the closest distance in right partition
While merging the two partition, we have to find if there is pair of tip which are even closer than the two pairs of absent and right panel,
In extra words, we have to locate a pair of point, one form left divider and the other as of right partition, such that distance d amongst them is less so as to dl and dr.
to do that , we be able to assume d to exist min(dl,dr) and find points in the distance d from the divider line.
As in the most horrible case, one point can exist in on the edge of one divider, and other point may reside at a coldness d on the other subpart at the identical horizontal height (same y coordinate)
Thus,
we are look only at smaller rectangle of width mains from the partition line only.
If u in addition to v be the closest point such that u is from absent partition and v is as of right panel, both u and v must be surrounded by d of the partition line (merging edge of two partition).
Thus it takes O(n log n)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.