Lec15 - Proximity Closest pair divide-and-conquer Closest...

Info icon This preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Closest pair CLOSEST PAIR INSTANCE: Set S = { p 1 , p 2 , ..., p N } of N points in the plane. QUESTION: Determine the two points of S whose mutual distance is smallest. We’ve seen a proof that CLOSEST PAIR has a lower bound for time ( N log N ). We seek an algorithm with upper bound O ( N log N ). If found, these together imply that CLOSEST PAIR θ ( N log N ). Two algorithm paradigms come to mind for O ( N log N ): 1. Sorting 2. Divide-and-conquer To use sorting, a total ordering of the points is needed, but none seem useful. For example, projecting the points of S onto the y axis give a total ordering on y coordinate but destroys useful information: points p 1 and p 2 are closest in Euclidean distance but farthest in y distance. Proximity Closest pair, divide-and-conquer
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Divide-and-conquer, concept Using the divide-and-conquer paradigm, time in O ( N log N ) can be achieved by: 1. Dividing the problem into two equal-sized subproblems 2. Solving those subproblems recursively 3. Merging the subproblem solutions into an overall solution in linear O ( N ) time. Unfortunately, it is not immediately obvious how to perform the merge in linear time. Suppose the problem has been solved for subproblem sets S 1 and S 2 , where S 1 S 2 = S , S 1 S 2 = , | S 1 | | S 2 | N /2; giving a closest pair of points for S 1 and another for S 2 . How can the closest pair for S be found? It may consist of one point from S 1 and one from S 2 . Testing all possible pairs of points from S 1 and S 2 requires time in O ( N /2) · O ( N /2) O ( N 2 ), which is unsatisfactory. Proximity Closest pair, divide-and-conquer S 1 S 2
Image of page 2
Divide-and-conquer for d = 1, 1 We consider a divide-and-conquer algorithm for CLOSEST PAIR in 1 dimension ( d = 1). Partition S , a set of points on a line, into two sets S 1 and S 2 at some point m such that for every point p S 1 and q S 2 , p < q . Solving CLOSEST PAIR recursively on S 1 and S 2 separately produces { p 1 , p 2 }, the closest pair in S 1 , and { q 1 , q 2 }, the closest pair in S 2 . Let δ be the smallest distance found so far: δ = min(| p 2 - p 1 |, | q 2 - q 1 |) The closest pair in S is either { p 1 , p 2 } or { q 1 , q 2 } or some { p 3 , q 3 } with p 3 S 1 and q 3 S 2 . Proximity Closest pair, divide-and-conquer S 1 S 2 p 1 p 2 p 3 q 3 q 1 q 2 m
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Divide-and-conquer for d = 1, 2 To check for such a point { p 3 , q 3 }, is it necessary to test every possible pair of points in S 1 and S 2 ?
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern