Chan`sAlgorithm

Download Report

Transcript Chan`sAlgorithm

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