190 likes | 405 Views
Algorithms on grids. Natasha Gelfand. Geometry Seminar Fall 2006. Grids in computer science. Graphics and vision Collision detection, point location. Simulation. Grids in computer science. Grids for geometric proximity. Isolate and localize interesting events Proximity is local
E N D
Algorithms on grids Natasha Gelfand Geometry Seminar Fall 2006
Grids in computer science Geometry Seminar: Algorithms on Grids
Graphics and vision Collision detection, point location Simulation Grids in computer science Geometry Seminar: Algorithms on Grids
Grids for geometric proximity • Isolate and localize interesting events • Proximity is local • “Uniform” grids • Closest pair, k-Minimum enclosing disk • Adaptive grids • quadtrees Geometry Seminar: Algorithms on Grids
Closest pair • Given: n points in the plane • Return pair of pointsrealizing Geometry Seminar: Algorithms on Grids
Grids for points • Computing the grid takes linear time Geometry Seminar: Algorithms on Grids
r Sub-problem • Given a set P and a distance r, verify in linear time if CP(P)<r or CP(P) > r • Insert points sequentially • If CP(P) < r, p, qare in the same orneighboring cells • Can we search a cellin constant time? Geometry Seminar: Algorithms on Grids
Algorithm • If some cell contains more than 9 points, then CP(P)<r • Algorithm: • Insert points into the grid • If cell(p) contains more than 9 points, return CP(P) < r Geometry Seminar: Algorithms on Grids
Algorithm • If some cell contains more than 9 points, then CP(P)<r • Algorithm: • Insert points into the grid • If cell(p) contains more than 9 points, return CP(P) < r • Otherwise, compute • Constant time per point,running time O(n) r Geometry Seminar: Algorithms on Grids
Closest pair • Permute points P=<p1, p1, … , pn> • Let ri = CP({p1, …, pi}) • Can check if ri<ri-1in linear time • Good case: ri = ri-1 • Grid is already built, check in O(1) time • Bad case: ri < ri-1 • Rebuild grid, O(i) time • Trivial bound: O(nk), when closest pair changes k times Geometry Seminar: Algorithms on Grids
Analysis • Let Xi = 1 if ri· ri-1, and 0 otherwise • Running time: Geometry Seminar: Algorithms on Grids
Analysis • Bound Pr[Xi = 1] = Pr[ri < ri-1] • Likelihood that pirealizes CP(Pi) • Expected running time Geometry Seminar: Algorithms on Grids
k-Enclosing minimum disk • Disk of minimum radius that contains k points • Brute forceO(nk) • 2-Opt algorithm: r(P,k) · 2ropt(P,k) k=4 k=3 Geometry Seminar: Algorithms on Grids
Non-uniform grid • Partition P into horizontal strips with at most k/4 points in each strip • Recursive median partitioning • O(n/k) strips Running time: T(n) = n + 2T(n/2) Stop at n < k/4 O(nlog(n/k)) G Geometry Seminar: Algorithms on Grids
Finite centers • Claim: Dopt(P,k) contains at least one intersection point of G • Pf: By contradiction: k/4points k/4points Dopt(P,k) k points At most k/2 points Geometry Seminar: Algorithms on Grids
Algorithm • For each grid intersection point g2G • Compute smallest circle centered at p with k points • k-th order statistic of{||p, g||} • Expected timeO(n) • Return the best of(n/k)2 candidates • Running time: O(n(n/k)2) Geometry Seminar: Algorithms on Grids
Correctness • 2-Opt: r(P,k) · 2ropt(P,k) Geometry Seminar: Algorithms on Grids