convex hull: ordering the points. - usi informatics · convex hull: ordering the points. elena...
TRANSCRIPT
![Page 1: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/1.jpg)
Convex Hull: Ordering the Points.
Elena Khramtcova
Algorithms and Data Structures.Faculty of Informatics, USI
Spring 2013
![Page 2: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/2.jpg)
Definition of convex hull (CH)
P – set of n points in the plane,
Problem(CH): Compute CH(P).
![Page 3: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/3.jpg)
Definition of convex hull (CH)
P – set of n points in the plane,
Problem(CH): Compute CH(P).
CH(P): smallest convex set containing P.
![Page 4: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/4.jpg)
Definition of convex hull (CH)
P – set of n points in the plane,
Problem(CH): Compute CH(P).
CH(P): smallest convex set containing P.
![Page 5: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/5.jpg)
Definition of convex hull (CH)
P – set of n points in the plane,
Problem(CH): Compute CH(P).
h – # of hull points
p1
p2p3
p4
p5
p6
p7
![Page 6: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/6.jpg)
Sorting can be reduced to CH
A – array of n numbers,
Problem: Compute B = sorted A.
(A[3],0)
(A[2],0)
(A[9],0)
(A[6],0)
(A[4],0)
(A[8],0)
(A[1],0)
(A[5],0)
(A[7],0)
![Page 7: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/7.jpg)
Sorting can be reduced to CH
A – array of n numbers,
Problem: Compute B = sorted A.
![Page 8: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/8.jpg)
Sorting can be reduced to CH
A – array of n numbers,
Problem: Compute B = sorted A.
![Page 9: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/9.jpg)
Sorting can be reduced to CH
A – array of n numbers,
Problem: Compute B = sorted A.
p1
p2p3
p4 p5p6
p7
p8
p9
![Page 10: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/10.jpg)
Sorting can be reduced to CH
A – array of n numbers,
Problem: Compute B = sorted A.
p1
p2p3
p4 p5p6
p7
p8
p9
(B[1],0) ... (B[9],0)
![Page 11: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/11.jpg)
CH algorithm 1: Jarvis’s march/Jarvis’s wrap
1. Find the lowest point p1
2. Do
Find pnext : min.angle withsupporting line
While pnext ! = p1
Time complexity: O(nh)
![Page 12: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/12.jpg)
CH algorithm 1: Jarvis’s march/Jarvis’s wrap
1. Find the lowest point p1
2. Do
Find pnext : min.angle withsupporting line
While pnext ! = p1
Time complexity: O(nh)
p1
![Page 13: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/13.jpg)
CH algorithm 1: Jarvis’s march/Jarvis’s wrap
1. Find the lowest point p1
2. Do
Find pnext : min.angle withsupporting line
While pnext ! = p1
Time complexity: O(nh)
p1
![Page 14: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/14.jpg)
CH algorithm 1: Jarvis’s march/Jarvis’s wrap
1. Find the lowest point p1
2. Do
Find pnext : min.angle withsupporting line
While pnext ! = p1
Time complexity: O(nh)
p1
![Page 15: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/15.jpg)
CH algorithm 1: Jarvis’s march/Jarvis’s wrap
1. Find the lowest point p1
2. Do
Find pnext : min.angle withsupporting line
While pnext ! = p1
Time complexity: O(nh)
p1
p2
![Page 16: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/16.jpg)
CH algorithm 1: Jarvis’s march/Jarvis’s wrap
1. Find the lowest point p1
2. Do
Find pnext : min.angle withsupporting line
While pnext ! = p1
Time complexity: O(nh)
p1
p2
![Page 17: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/17.jpg)
CH algorithm 1: Jarvis’s march/Jarvis’s wrap
1. Find the lowest point p1
2. Do
Find pnext : min.angle withsupporting line
While pnext ! = p1
Time complexity: O(nh)
p1
p2
p3
![Page 18: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/18.jpg)
CH algorithm 1: Jarvis’s march/Jarvis’s wrap
1. Find the lowest point p1
2. Do
Find pnext : min.angle withsupporting line
While pnext ! = p1
Time complexity: O(nh)
p1
p2
p3
p4
![Page 19: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/19.jpg)
CH algorithm 1: Jarvis’s march/Jarvis’s wrap
1. Find the lowest point p1
2. Do
Find pnext : min.angle withsupporting line
While pnext ! = p1
Time complexity: O(nh)
p1
p2
p3
p4p5
![Page 20: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/20.jpg)
CH algorithm 1: Jarvis’s march/Jarvis’s wrap
1. Find the lowest point p1
2. Do
Find pnext : min.angle withsupporting line
While pnext ! = p1
Time complexity: O(nh)
p1
p2
p3
p4p5
p6
![Page 21: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/21.jpg)
CH algorithm 1: Jarvis’s march/Jarvis’s wrap
1. Find the lowest point p1
2. Do
Find pnext : min.angle withsupporting line
While pnext ! = p1
Time complexity: O(nh)
p1
p2
p3
p4p5
p6
p7
![Page 22: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/22.jpg)
CH algorithm 1: Jarvis’s march/Jarvis’s wrap
1. Find the lowest point p1
2. Do
Find pnext : min.angle withsupporting line
While pnext ! = p1
Time complexity: O(nh) p1
p2
p3
p4p5
p6
p7
![Page 23: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/23.jpg)
CH algorithm 2: ...
1. Divide points by avertical line in twoequal parts
2. Compute CH(Pleft) andCH(Pright) recursively
3. Find two bridges
4. Delete all edgesin-between the bridges
Time complexity: O(n log n)
![Page 24: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/24.jpg)
CH algorithm 2: ...
1. Divide points by avertical line in twoequal parts
2. Compute CH(Pleft) andCH(Pright) recursively
3. Find two bridges
4. Delete all edgesin-between the bridges
Time complexity: O(n log n)
![Page 25: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/25.jpg)
CH algorithm 2: ...
1. Divide points by avertical line in twoequal parts
2. Compute CH(Pleft) andCH(Pright) recursively
3. Find two bridges
4. Delete all edgesin-between the bridges
Time complexity: O(n log n)
![Page 26: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/26.jpg)
CH algorithm 2: ...
1. Divide points by avertical line in twoequal parts
2. Compute CH(Pleft) andCH(Pright) recursively
3. Find two bridges
4. Delete all edgesin-between the bridges
Time complexity: O(n log n)
![Page 27: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/27.jpg)
CH algorithm 2: ...
1. Divide points by avertical line in twoequal parts
2. Compute CH(Pleft) andCH(Pright) recursively
3. Find two bridges
4. Delete all edgesin-between the bridges
Time complexity: O(n log n)
![Page 28: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/28.jpg)
CH algorithm 2: ...
1. Divide points by avertical line in twoequal parts
2. Compute CH(Pleft) andCH(Pright) recursively
3. Find two bridges
4. Delete all edgesin-between the bridges
Time complexity: O(n log n)
![Page 29: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/29.jpg)
CH algorithm 2: Divide and Conquer
1. Divide points by avertical line in twoequal parts
2. Compute CH(Pleft) andCH(Pright) recursively
3. Find two bridges
4. Delete all edgesin-between the bridges
Time complexity: O(n log n)
![Page 30: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/30.jpg)
CH algorithm 3: ...
1. Find points r and l
2. Divide the set by rl into Aand B
3. Return HULL(A, l , r)∪HULL(B, r , l)
HULL(A, l , r)if A = lr , return (l , r) else
1. Find z ∈ A: farthest fromlr
2. R – points to the right of lz
3. L – points to the left of zr
4. Return{HULL(L, l , z) ∪ {z}∪HULL(R, z , r)}
Time complexity: O(n2) w.c.,O(n log n) avg.
![Page 31: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/31.jpg)
CH algorithm 3: ...
1. Find points r and l
2. Divide the set by rl into Aand B
3. Return HULL(A, l , r)∪HULL(B, r , l)
l
r
HULL(A, l , r)if A = lr , return (l , r) else
1. Find z ∈ A: farthest fromlr
2. R – points to the right of lz
3. L – points to the left of zr
4. Return{HULL(L, l , z) ∪ {z}∪HULL(R, z , r)}
Time complexity: O(n2) w.c.,O(n log n) avg.
![Page 32: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/32.jpg)
CH algorithm 3: ...
1. Find points r and l
2. Divide the set by rl into Aand B
3. Return HULL(A, l , r)∪HULL(B, r , l)
l
r
HULL(A, l , r)if A = lr , return (l , r) else
1. Find z ∈ A: farthest fromlr
2. R – points to the right of lz
3. L – points to the left of zr
4. Return{HULL(L, l , z) ∪ {z}∪HULL(R, z , r)}
Time complexity: O(n2) w.c.,O(n log n) avg.
![Page 33: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/33.jpg)
CH algorithm 3: ...
1. Find points r and l
2. Divide the set by rl into Aand B
3. Return HULL(A, l , r)∪HULL(B, r , l)
l
r
z
l
r
HULL(A, l , r)if A = lr , return (l , r) else
1. Find z ∈ A: farthest fromlr
2. R – points to the right of lz
3. L – points to the left of zr
4. Return{HULL(L, l , z) ∪ {z}∪HULL(R, z , r)}
Time complexity: O(n2) w.c.,O(n log n) avg.
![Page 34: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/34.jpg)
CH algorithm 3: ...
1. Find points r and l
2. Divide the set by rl into Aand B
3. Return HULL(A, l , r)∪HULL(B, r , l)
z
l
r
HULL(A, l , r)if A = lr , return (l , r) else
1. Find z ∈ A: farthest fromlr
2. R – points to the right of lz
3. L – points to the left of zr
4. Return{HULL(L, l , z) ∪ {z}∪HULL(R, z , r)}
Time complexity: O(n2) w.c.,O(n log n) avg.
![Page 35: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/35.jpg)
CH algorithm 3: ...
1. Find points r and l
2. Divide the set by rl into Aand B
3. Return HULL(A, l , r)∪HULL(B, r , l)
HULL(A, l , r)if A = lr , return (l , r) else
1. Find z ∈ A: farthest fromlr
2. R – points to the right of lz
3. L – points to the left of zr
4. Return{HULL(L, l , z) ∪ {z}∪HULL(R, z , r)}
Time complexity: O(n2) w.c.,O(n log n) avg.
![Page 36: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/36.jpg)
CH algorithm 3: Quickhull
1. Find points r and l
2. Divide the set by rl into Aand B
3. Return HULL(A, l , r)∪HULL(B, r , l)
HULL(A, l , r)if A = lr , return (l , r) else
1. Find z ∈ A: farthest fromlr
2. R – points to the right of lz
3. L – points to the left of zr
4. Return{HULL(L, l , z) ∪ {z}∪HULL(R, z , r)}
Time complexity: O(n2) w.c.,O(n log n) avg.
![Page 37: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/37.jpg)
CH algorithm 4: Heaphull. It does exist!
Uses a kinetic heap w.r.t. a certain “up” direction
Time complexity: O(n log2 n)
![Page 38: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/38.jpg)
CH algorithm 4: Heaphull. It does exist!
⇒
up up
Uses a kinetic heap w.r.t. a certain “up” directionTime complexity: O(n log2 n)
![Page 39: Convex Hull: Ordering the Points. - USI Informatics · Convex Hull: Ordering the Points. Elena Khramtcova Algorithms and Data Structures. Faculty of Informatics, USI Spring 2013](https://reader036.vdocument.in/reader036/viewer/2022062603/5f0333d57e708231d4080b45/html5/thumbnails/39.jpg)
Not covered here
I Graham scan
I Chan’s algorithm
I Randomized incremental construction
I 3- and d-dimension