Merging two upper hulls
description
Transcript of Merging two upper hulls
![Page 1: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/1.jpg)
Advanced Topics in Algorithms and Data Structures
Lecture 7.2, page 1
Merging two upper hulls
• Suppose, UH(S2) has s points given in an array according to their order on UH(S2).
• We allocate processors and divide the points on UH(S2) into intervals and do a parallel search.
• We can identify the point in time.
s
irq log
( ) (1)log
sO O
s
s
![Page 2: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/2.jpg)
Advanced Topics in Algorithms and Data Structures
Lecture 7.2, page 2
Merging two upper hulls
• Suppose, the common tangent to UH(S1) and UH(S2) is the line .
• u is on UH(S1) and v is on UH(S2) .
• If we know the line , we can say in O(1) time whether u is above or below the line .
uv
ii rrq
ii rrq
![Page 3: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/3.jpg)
Advanced Topics in Algorithms and Data Structures
Lecture 7.2, page 3
Merging two upper hulls
• Suppose, there are t points on UH(S1), given in an array according to their order on UH(S1).
• We divide these t points in intervals, each interval contains points.
• We now do a parallel search in the following ways.
tt
![Page 4: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/4.jpg)
Advanced Topics in Algorithms and Data Structures
Lecture 7.2, page 4
Merging two upper hulls
• We allocate processors for the parallel search.
• Suppose ri is the boundary vertex of one of the intervals.
• For each such ri, we can find the tangent to UH(S2) in O(1) time using processors.
t s
sii rrq
![Page 5: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/5.jpg)
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
![Page 6: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/6.jpg)
Advanced Topics in Algorithms and Data Structures
Lecture 7.2, page 6
Merging two upper hulls
• Hence, we can identify two boundary vertices rj and rk such that u is above rj and below rk.
• Hence, u must be one of the vertices in between rj and rk.
• This computation takes O(1) time and processors.
t
( )s t O n
![Page 7: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/7.jpg)
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(S2) in which v is a member.
• This computation again takes O(1) time and processors.
s
( )s t O n
![Page 8: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/8.jpg)
Advanced Topics in Algorithms and Data Structures
Lecture 7.2, page 8
Merging two upper hulls
• Now, we have vertices on UH(S2) and vertices on UH(S1) .
• There are possible lines if we join one point from UH(S1) and one point from UH(S2) .
• For each of these O(n) lines, we can check in O(1) time whether the line is a common tangent to UH(S1) and UH(S2) .
s t
( )s t O n
![Page 9: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/9.jpg)
Advanced Topics in Algorithms and Data Structures
Lecture 7.2, page 9
Merging two upper hulls
• Suppose, is one such line.
• ul and ur are the two neighboring vertices of u. Also, vl and vr are the two neighboring vertices of v.
• is the common tangent to both UH(S1) and UH(S2) if all the point ul, ur, vl, vr are below .
uv
uvuv
![Page 10: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/10.jpg)
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(S1) and UH(S2) in O(1) time and O(n) work.
• We can form another array of vertices containing the vertices in UH(S1) UH(S2) by deleting some parts of the arrays of UH(S1) and UH(S2) and merging the remaining parts.
![Page 11: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/11.jpg)
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.
![Page 12: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/12.jpg)
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.
![Page 13: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/13.jpg)
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.
![Page 14: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/14.jpg)
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).
![Page 15: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/15.jpg)
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 L1, L2,…,Ln, and the region C
defined by 1 i n H+(Li) – The region C consists of all the points above all the
lines Li,1 i n
![Page 16: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/16.jpg)
Advanced Topics in Algorithms and Data Structures
Lecture 7.2, page 16
Intersection of half planes
• In the transformed domain, T(C+) = { T(p) | pC+ } consists of all the lines above all the points T(Li), for 1 i n.
![Page 17: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/17.jpg)
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.
![Page 18: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/18.jpg)
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.
![Page 19: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/19.jpg)
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.
![Page 20: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/20.jpg)
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: aix + biy + ci 0, 1 i n.
(Constraints)
![Page 21: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/21.jpg)
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.
![Page 22: Merging two upper hulls](https://reader036.fdocuments.us/reader036/viewer/2022062301/56815a86550346895dc7f46c/html5/thumbnails/22.jpg)
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.