Chan`sAlgorithm

advertisement
Chan’s algorithm
CS504 Presentation
Planar Convex Hull
• Graham’s Scan : 𝑂(𝑛 log 𝑛)
• Jarvis’s March : 𝑂(π‘›β„Ž)
• Is there any 𝑂(𝑛 log β„Ž) algorithm?
CS504 Presentation
Chan’s Algorithm
• Chan’s algorithm
– combining Graham’s scan and Jarvis’s March together
– 𝑂 𝑛 log β„Ž
• 3 stages of Chan’s algorithm
1.
2.
3.
divide vertices into partitions
apply Graham’s scan on each partition
apply Jarvis’s March on the small convex hull
(repeat 1~3 until we find the hull)
CS504 Presentation
Chan’s Algorithm
• Stage1 : Partition
• Consider arbitrary value π‘š < 𝑛, the size of partition
– how to decide π‘š will be treated later
• Partition the points into groups, each of size π‘š
– π‘Ÿ=
𝑛
π‘š
is the number of groups
CS504 Presentation
Chan’s Algorithm
• Stage 1
n = 32
Set m = 8
CS504 Presentation
Chan’s Algorithm
• Stage 1
n = 32
Set m = 8
r=4
CS504 Presentation
Chan’s Algorithm
• Stage2 : Graham’s Scan
• Compute convex hull of each partition using Graham’s
scan
• Total 𝑂(𝑛 log π‘š) time
CS504 Presentation
Chan’s Algorithm
• Stage 2
(After Stage 1)
m=8
r=4
CS504 Presentation
Chan’s Algorithm
• Stage 2
Using Graham’s Scan
O π‘š log π‘š for each group
-> total 𝑂(π‘šπ‘Ÿ log π‘š)
= 𝑂(𝑛 log π‘š)
CS504 Presentation
Chan’s Algorithm
• Stage3 : Jarvis’s March
• How to merge these r hulls into a single hull?
• IDEA : treat each hull as a “fat point” and run Jarvis’s
March!
• # of iteration is at most m
– to guarantee the time complexity O(nlogh)
CS504 Presentation
Chan’s Algorithm
• (-inf,0) -> lowest pt
(−∞, 0)
lowest pt
CS504 Presentation
Chan’s Algorithm
• Find the point that maximize the angle in each hull
(−∞, 0)
1
lowest pt
CS504 Presentation
Chan’s Algorithm
• Find the point that maximize the angle in each hull
(−∞, 0)
2
1
lowest pt
CS504 Presentation
Chan’s Algorithm
• Find the point that maximize the angle in each hull
3
(−∞, 0)
2
1
lowest pt
CS504 Presentation
Chan’s Algorithm
If π‘š < β„Ž, then the algorithm will fail!
CS504 Presentation
Chan’s Algorithm
• FAIL EXAMPLE – too small value m
m=4
(−∞, 0)
4 iteration
CS504 Presentation
Chan’s Algorithm
In 4(a), how to find such points?
CS504 Presentation
Chan’s Algorithm
• Find the point that maximize the angle in each hull
(−∞, 0)
1
lowest pt
CS504 Presentation
Chan’s Algorithm
• Find the point that maximize the angle in a hull
(−∞, 0)
CS504 Presentation
Chan’s Algorithm
• Finding tangent between a point and a convex π‘š-gon
5
1
𝑂 log π‘š process
4
3
2
CS504 Presentation
Chan’s Algorithm
→ 𝑂(log π‘š)
CS504 Presentation
Chan’s Algorithm
Analysis
• Suppose God told you some good value for π‘š
– β„Ž ≤ π‘š ≤ β„Ž2
• 𝑂 𝑛 log π‘š for stage1~2
• At most h steps in Jarvis’s March
– 𝑂(log π‘š) time to compute each tangent
– π‘Ÿ tangent for each iteration
𝑛
– total 𝑂 β„Žπ‘Ÿ log π‘š = 𝑂(β„Ž π‘š log π‘š) time
• 𝑂
𝑛+β„Ž
𝑛
π‘š
log π‘š = 𝑂 𝑛 log π‘š = 𝑂(𝑛 log β„Ž) as desired.
π‘š ≤ β„Ž2
CS504 Presentation
Chan’s Algorithm
• The only question remaining is…
how do we know what value to give to π‘š?
CS504 Presentation
Chan’s Algorithm
• Answer : square search
• Try this way - π‘š =
𝑑
2
2, 4, 8, … , 2 , …
• Then we eventually get π‘š to be in [β„Ž, β„Ž2 ] !
CS504 Presentation
Chan’s Algorithm
• The algorithm stops as soon as
𝑑
2
2
≥β„Ž
– 𝑑 = lg lg β„Ž
• Total time complexity
lg lg β„Ž
lg lg β„Ž
𝑛 log 2
𝑑=1
2𝑑
𝑛2𝑑 ≤ 𝑛 21+lg lg β„Ž = 2𝑛 2lg lg β„Ž
=
𝑑=1
= 2𝑛 log β„Ž = 𝑂(𝑛 log β„Ž)
CS504 Presentation
Download