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