Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 1 An overview of lecture 7 An optimal parallel algorithm for the 2D convex hull problem,

Similar presentations


Presentation on theme: "Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 1 An overview of lecture 7 An optimal parallel algorithm for the 2D convex hull problem,"— Presentation transcript:

1 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 1 An overview of lecture 7 An optimal parallel algorithm for the 2D convex hull problem, Some applications of the 2D convex hull algorithm.

2 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 2 The convex hull problem Input: A set S = ( p 1, p 2,…, p n ) of n points on the plane. Output: The convex hull CH ( S ) of these n points. The convex hull is the smallest convex polygon containing all the n points. Each vertex of CH ( S ) is called an extreme point and the convex hull is output as a list of the extreme points.

3 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 3 The convex hull problem Let p max and p min be two points in the set S with the maximum and minimum x coordinates. Then p max and p min are convex hull vertices. The line segment divides the convex hull into two parts, upper hull and lower hull.

4 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 4 The convex hull problem We use the notation x ( p ) and y ( p ) to denote the x and y coordinates of a point p. Given a line L specified by the equation y = ax + b, and a point q =( ,  ), We say, q is below L if  < a  + b. We also say, q is above L if  > a  + b.

5 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 5 The convex hull problem Given the set S of n points, we can find p max and p min in O ( n ) time. We can find all the points above and below also in O ( n ) time. We can compute the convex hull of all the points above and call this as UH ( S ). Similarly, we can compute the convex hull of all the points below and call this as LH ( S ). At the end, we can stitch these two hulls together at the two points p max and p min.

6 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 6 Sequential complexity The convex hull of n planar points can be constructed in  ( n log n ) time sequentially. The lower bound can be proved by showing that the convex hull problem is equivalent to sorting. We need to design an O ( n log n ) work algorithm to achieve optimality.

7 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 7 Computing the upper hull We will discuss an algorithm for computing the upper hull of the set S. The algorithm for computing the lower hull is exactly the same. A line L is tangent to a convex polygon P if all the vertices of P are on the same side of L.

8 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 8 A divide-and-conquer algorithm We discuss a divide-and-conquer algorithm for computing the upper hull. There are two phases, top-down and bottom-up. First, we sort the points according to x - coordinates.

9 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 9 A divide-and-conquer algorithm In the top-down phase, we divide the point set recursively into two parts and compute the convex hull when the size of each subproblem is small. In the bottom-up phase, we merge these hulls pairwise to get the upper hull. The strategy is exactly similar to the sequential algorithm for merge sort.

10 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 10 A divide-and-conquer algorithm

11 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 11 Merging two upper hulls The main problem in combining two upper hulls to form a single upper hull is to compute a common tangent to the two hulls. To achieve O ( n log n ) work, we need to complete the merging of all the upper hulls at a level of the tree in O (1) time.

12 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 12 Merging two upper hulls We consider two upper hulls UH ( S 1 ) and UH ( S 2 ). Our aim is to find a common tangent to these two upper hulls. We first find a tangent to UH ( S 2 ) from a point r i on UH ( S 1 ).

13 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 13 Merging two upper hulls Suppose the line is the tangent to UH ( S 2 ) from r i. Suppose q l is another vertex of UH ( S 2 ). Given the line r i q l, we first try to locate.

14 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 14 Merging two upper hulls In O (1) time, we can say whether is above or below the line. If the neighboring vertices q l -1 and q l +1 of q l are on either side of, then is above q l.

15 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 15 Parallel search algorithm For each of the p + 1 parts of the array, a processor checks whether y < x l, where x l is the last element of the part. If y x l, the subarray to the left of x l can be rejected. In each iteration we identify only one subarray for further search.

16 Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 16 Complexity of parallel searching We need to analyze what is the complexity of reducing the size of the array to p. At the first iteration, we are reducing the size of the array from n to n / p. Suppose, the size reduces to p after k iterations. Hence,, which implies n = p k +1.. We need the CREW PRAM model.


Download ppt "Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 1 An overview of lecture 7 An optimal parallel algorithm for the 2D convex hull problem,"

Similar presentations


Ads by Google