Professional Documents
Culture Documents
Kir CK Patrick Seidel
Kir CK Patrick Seidel
Kir CK Patrick Seidel
problem
CS F364
Instructor: Dr. Tathagata Ray
So here we start
• Find the convex hull of a given set of points on
a plane?
• Helps parallelizability !
Apply it on convex hull
• Input point set P.
• Divide it into P1 and P2.
• Lets say somehow we can find CH(P1) and
CH(P2).
• Great property CH(P) = CH( CH(P1) U CH (P2) )
The Algorithm
• procedure divide-and-conquer(S);
• 1. If |S|< ko (where ko is some small integer), then
construct the convex hull of S by some other
method. If not, go to step 2.
• 2. Partition S into two subsets ,S1 and S2 of
approximately equal size.
• 3. Recursively find the convex hulls of S1 and S2.
• 3. Merge the two convex hulls CH(S1) and CH(S2)
together to form CH(S).
How will you merge
How will you merge
Upper Bridge
u2
u1
l1
l2
Lower Bridge
How will you merge
Upper Bridge
u2
u1
Delete
l1
l2
Lower Bridge
The Kirkpatrick-Seidel algorithm
• A variation of divide and conquer strategy.
pmin pmax
The algorithm
2. Find the median of the x-coordinates of the points in T i.e.
find an a such that
• x(p) ≤ a for |T|/2 points in T and
• x(p) ≥ a for |T|/2 points in T
• Let L be the vertical line x = a. Let Tleft be the points of T to the
left of L. Let Tright be the points of T to the right of L.
Tleft L Tright
pmin pmax
The algorithm
• 3. Define the upper bridge to be the segment such that its
left end-point pl lies in Tleft and its right end-point pr, lies in
Tright, and it is a supporting line of T. Clearly, the upper bridge
is a part of the upper convex hull.
• We will show later that there is an algorithm to determine
upper bridges efficiently (pl, pr) := UPPER-BRIDGE(T, L);
Tleft pl L pr Tright
pmin pmax
Definition of Supporting Line
• Supporting line of S is a nonvertical straight
line which contains at least one point of S but
has no points of S above it.
It is a supporting
line
Not a
supporting line
The algorithm
4. Since pmax, pl, pr, and pmin, are all points in T , and they form a
convex quadrilateral, we can discard all points of T that fall within
this quadrilateral , since they cannot form the vertices of the upper
hull.
• Tleft:= {pl} U all the points of Tleft to the left of the line through pmin
and pl;
• Tright := {pr} U all the points of Trightto the right of the line through pr
and pmax;
T pl L pr Tright
left
pmin pmax
The algorithm
• UPPER-HULL(pmin, pl, Tleft) * UPPER-HULL(pr,
pmax, Tright), where * represents list
concatenation of doubly linked lists.
• Find the LOWER-HULL(pmax, pr, Tright) * LOWER-
HULL(pl, pmin, Trleft),
Finding the Upper Bridge
It is a supporting
line
Not a
supporting line
• Lemma 3: Let h be a supporting line of S with
slope mh, and let the point(s) of S that it
contains belong to the upper hull.
– mh > mb iff h contains only points of S that are to
the left of or on L (dividing line).
– mh < mb iff h contains only points of S that are to
the right of L .
Lemma 3
Lemma 2 + Lemma 3
• Corollary : Let p, q be points in S with x(p) <
x(q), and h be any supporting line of S. Then
– If h contains only points of S to the left of or on L
(means mh > mb ) and mpq > mh ( > mb), then using
lemma 2, p is not a candidate for the end point of
the bridge.
– If h contains only points of S to the right of L
(means mh < mb ) and mpq < mh ( < mb), then using
lemma 2, q is not a candidate for the end point of
the bridge.
The Upper_Bridge Algo
Analysis
• Theorem: UPPER-BRIDGE runs in O(n) worst
case time.
• Proof: The median finding operation will take
linear time in step 4.
• In step 3, 8 and 9. at least one quarter of the
points of S are eliminated and hence are not
contained in CANDIDATES.
• So the recurrence is f(n) = f(3n/4) + O(n).
• The solution is O(n)
UPPER-HULL
• Claim: UPPER-HULL takes O(N log Hu) time,
where Hu is the number of vertices on the
upper hull, and N is the size of the input.
• Assumption:
– UPPER_BRIDGE () takes linear time.
– Median finding operation is linear time.
• So Step 2 to 4 takes O(N) time.
Let T(n,h) be the recurrence relation . Here c is a
Constant and n≥h>1. hl and hr are number of upper
hull edges in recursive calls for left and right side.
cn ifh 2
T (n, h) n n
cn max{T ( , hl ) T ( , hr ) | hl hr 1 h} o.w
2 2
f ( n, h )
Reference
• http://graphics.stanford.edu/courses/cs268-
16-fall/Notes/KirkSeidel.pdf
• Suneeta Ramaswami. Convex Hulls:
Complexity and Applications (A Survey) .
Technical report. Dept of Computer Science,
Upenn, 1993.