# Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 1 Merging two upper hulls Suppose, UH ( S 2 ) has s points given in an array according.

## Presentation on theme: "Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 1 Merging two upper hulls Suppose, UH ( S 2 ) has s points given in an array according."— Presentation transcript:

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 1 Merging two upper hulls Suppose, UH ( S 2 ) has s points given in an array according to their order on UH ( S 2 ). We allocate processors and divide the points on UH ( S 2 ) into intervals and do a parallel search. We can identify the point in time.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 2 Merging two upper hulls Suppose, the common tangent to UH ( S 1 ) and UH ( S 2 ) is the line. u is on UH ( S 1 ) and v is on UH ( S 2 ). If we know the line, we can say in O (1) time whether u is above or below the line.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 3 Merging two upper hulls Suppose, there are t points on UH ( S 1 ), given in an array according to their order on UH ( S 1 ). We divide these t points in intervals, each interval contains points. We now do a parallel search in the following ways.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 4 Merging two upper hulls We allocate processors for the parallel search. Suppose r i is the boundary vertex of one of the intervals. For each such r i, we can find the tangent to UH ( S 2 ) in O (1) time using processors.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 5 Merging two upper hulls u is to the left of (along the polygonal chain of UH(S )) if and only if is above

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 6 Merging two upper hulls Hence, we can identify two boundary vertices r j and r k such that u is above r j and below r k. Hence, u must be one of the vertices in between r j and r k. This computation takes O (1) time and processors.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 7 Merging two upper hulls We can do a similar computation to find a group of vertices on UH ( S 2 ) in which v is a member. This computation again takes O (1) time and processors.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 8 Merging two upper hulls Now, we have vertices on UH ( S 2 ) and vertices on UH ( S 1 ). There are possible lines if we join one point from UH ( S 1 ) and one point from UH ( S 2 ). For each of these O ( n ) lines, we can check in O (1) time whether the line is a common tangent to UH ( S 1 ) and UH ( S 2 ).

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 9 Merging two upper hulls Suppose, is one such line. u l and u r are the two neighboring vertices of u. Also, v l and v r are the two neighboring vertices of v. is the common tangent to both UH ( S 1 ) and UH ( S 2 ) if all the point u l, u r, v l, v r are below.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 10 Merging two upper hulls For each of the O ( n ) lines, we can check this condition in O (1) time. Hence, we can find a common tangent to UH ( S 1 ) and UH ( S 2 ) in O (1) time and O ( n ) work. We can form another array of vertices containing the vertices in UH ( S 1 )  UH ( S 2 ) by deleting some parts of the arrays of UH ( S 1 ) and UH ( S 2 ) and merging the remaining parts.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 11 The convex hull algorithm We solve the problem through a divide and conquer strategy. The depth of the recursion is O (log n ) and we can do the merging of the convex hulls at every level of the recursion in O (1) time and O ( n ) work. Hence, the overall time required is O (log n ) and the overall work done is O ( n log n ) which is optimal. We need the CREW PRAM model due to the concurrent reading in the parallel search algorithm.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 12 Intersection of half planes Consider a line L defined by the equation y = ax + b. L divides the entire plane into two half planes, H + ( L ) and H - ( L ). H + ( L ) consists of all the points ( ,  ) such that   a  + b. Similarly, H - ( L ) consists of all the points   a  + b. Intuitively, H + ( L ) is the set of points on or above the line L, And, H - ( L ) is the set of points on or below the line L.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 13 Intersection of half planes For a set of lines, the intersection of the positive half planes defined by these lines is a convex region. However, the intersection may or may not be bounded. Our aim is to compute the boundary of the intersection.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 14 Dual transform Let T be a transformation that maps a point p = ( a, b ) into the line T ( p ) defined by y = ax + b. The reverse transformation maps the line L : y = ax + b into the point T ( L ) = (- a, b ).

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 15 A property Property: A point p is below a line L if and only if T ( p ) is below the point T ( L ). –Consider a set of lines L 1, L 2,…, L n, and the region C defined by  1  i  n H + ( L i ) –The region C consists of all the points above all the lines L i,1  i  n

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 16 Intersection of half planes In the transformed domain, T ( C + ) = { T ( p ) | p  C + } consists of all the lines above all the points T ( L i ), for 1  i  n.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 17 Intersection of half planes The extreme points of the intersection of half planes are now the line segments between two consecutive vertices of the convex hull in the dual space.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 18 Intersection of half planes To compute the intersection of the half planes, we first convert the lines into their dual points. Then we compute the convex hull of these dual points. Finally, we get the extreme points of the intersection of half planes by converting the line segments between two consecutive extreme points of the convex hull into points.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 19 Intersection of half planes The transformations take O (1) time each if we allocate one processor for each line. The convex hull construction takes O (log n ) time and O ( n log n ) work on the CREW PRAM.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 20 Two variable linear program The two-variable linear program problem is defined as: Minimize cx + dy (Objective function) Subject to: a i x + b i y + c i  0, 1  i  n. (Constraints)

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 21 Two variable linear programming Each constraint is a half plane. The feasible region is a set of points satisfying all the constraints. The solution of the linear program is a point in the feasible region that minimizes the objective function. The objective function is minimized at one of the extreme points of the feasible region.

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 22 Two variable linear programming Hence, we can find all the O ( n ) extreme points of the feasible region by the half plane intersection algorithm. Then we can find the extreme point which minimizes the objective function. The algorithm takes O (log n ) time and O ( n log n ) work on the CREW PRAM.

Download ppt "Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 1 Merging two upper hulls Suppose, UH ( S 2 ) has s points given in an array according."

Similar presentations