CS468, Mon. Oct. 2nd, 2006 Quadtrees: Hierarchical Grids Steve Oudot From S. Har-Peled’s notes, Chapter 2
Outline • Examples and preliminary results. (deterministic) • Static setting: compressed quadtrees. • Dynamic setting: skip-quadtrees. (randomized) • Adaptive meshing: balanced quadtrees. (deterministic) 1
A first example (point location) Goal: given a planar map M that partitions [0 , 1[ 2 , preprocess M such that, for any query point q ∈ [0 , 1] 2 , the region containing q is found in sublinear time. q 2
A first example (point location) Goal: given a planar map M that partitions [0 , 1[ 2 , preprocess M such that, for any query point q ∈ [0 , 1] 2 , the region containing q is found in sublinear time. q - triangulate each region explain why quadtree can be interes 2
A first example (point location) Goal: given a planar map M that partitions [0 , 1[ 2 , preprocess M such that, for any query point q ∈ [0 , 1] 2 , the region containing q is found in sublinear time. (0 , 0) (0 , 0) - triangulate each region explain why quadtree can be interes - build quadtree T whose leaves intersect at most 9 triangles 2
A first example (point location) Goal: given a planar map M that partitions [0 , 1[ 2 , preprocess M such that, for any query point q ∈ [0 , 1] 2 , the region containing q is found in sublinear time. (0 , 0) (0 , 0) (0 . 1 , 0) (0 , 0 . 1) (0 . 1 , 0 . 1) lexicographical order (0 , 0 . 1) (0 . 1 , 0 . 1) - triangulate each region explain why quadtree can be interes (0 , 0) (0 . 1 , 0) - build quadtree T whose leaves intersect at most 9 triangles 2
A first example (point location) Goal: given a planar map M that partitions [0 , 1[ 2 , preprocess M such that, for any query point q ∈ [0 , 1] 2 , the region containing q is found in sublinear time. (0 , 0) (0 , 0) (0 . 1 , 0) (0 , 0 . 1) (0 . 1 , 0 . 1) (0 , 0 . 11) (0 . 01 , 0 . 11) (0 . 1 , 0 . 11) (0 . 11 , 0 . 11) lexicographical order (0 , 0 . 1) (0 . 01 , 0 . 1) (0 . 1 , 0 . 1) (0 . 11 , 0 . 1) (0 , 0 . 01) (0 . 01 , 0 . 01) (0 . 1 , 0 . 01) (0 . 11 , 0 . 01) - triangulate each region explain why quadtree can be interes - build quadtree T whose leaves (0 , 0) (0 . 01 , 0) (0 . 1 , 0) (0 . 11 , 0) intersect at most 9 triangles 2
A first example (point location) Goal: given a planar map M that partitions [0 , 1[ 2 , preprocess M such that, for any query point q ∈ [0 , 1] 2 , the region containing q is found in sublinear time. (0 , 0) (0 , 0) (0 . 1 , 0) (0 , 0 . 1) (0 . 1 , 0 . 1) lexicographical order - triangulate each region explain why quadtree can be interes - build quadtree T whose leaves intersect at most 9 triangles 2
A first example (point location) Goal: given a planar map M that partitions [0 , 1[ 2 , preprocess M such that, for any query point q ∈ [0 , 1] 2 , the region containing q is found in sublinear time. (0 , 0) (0 , 0) (0 . 1 , 0) (0 , 0 . 1) (0 . 1 , 0 . 1) lexicographical order cell � v node v - triangulate each region explain why quadtree can be interes - build quadtree T whose leaves intersect at most 9 triangles 2
A first example (point location) Goal: given a planar map M that partitions [0 , 1[ 2 , preprocess M such that, for any query point q ∈ [0 , 1] 2 , the region containing q is found in sublinear time. (0 , 0) (0 , 0) (0 . 1 , 0) (0 , 0 . 1) (0 . 1 , 0 . 1) q lexicographical order - ∀ q ∈ [0 , 1[ 2 , walk down T to find leaf v ∈ L that contains q, then check tri- angles that intersect � v . ⇒ size O ( | L | ) , time O ( h ) regular grid : size Θ(2 2 h ) , time O (1) can we do better? Q 2
A first example (point location) Goal: given a planar map M that partitions [0 , 1[ 2 , preprocess M such that, for any query point q ∈ [0 , 1] 2 , the region containing q is found in sublinear time. (0 , 0) (0 , 0) (0 . 1 , 0) (0 , 0 . 1) (0 . 1 , 0 . 1) q give example with q = (0 . 10101 , 0 . 1101) → v 0 = (0 . 1 , 0 lexicographical order - level i forms a 2 − i -regular grid of [0 , 1[ 2 2 − i ⌊ 2 i q x ⌋ , 2 − i ⌊ 2 i q y ⌋ ` ´ ⇒ ∀ i , v i ( q ) = morally, we chop off the digits of qx and qy after the ( i + 1) th → the recursive lexico - put nodes in hash-table - ∀ q ∈ [0 , 1[ 2 , binary search on height: Let i = hmax+hmin / 2 ; if vi ( q ) � = NULL , then search between i and hmax ; else search between hmin and i ; ⇒ O (log h ) = O (log log n ) if T balanced 2
Another example (range searching) Goal: given a finite point set P ⊂ [0 , 1[ 2 , preprocess P such that, for any query rectangle r ⊆ [0 , 1] 2 , r ∩ P is found in time O ( | r ∩ P | ) . r 3
Another example (range searching) Goal: given a finite point set P ⊂ [0 , 1[ 2 , preprocess P such that, for any query rectangle r ⊆ [0 , 1] 2 , r ∩ P is found in time O ( | r ∩ P | ) . Q: que gagne-t-on par rapport a une 3
Another example (range searching) Goal: given a finite point set P ⊂ [0 , 1[ 2 , preprocess P such that, for any query rectangle r ⊆ [0 , 1] 2 , r ∩ P is found in time O ( | r ∩ P | ) . Q: que gagne-t-on par rapport a une 1 point per leaf ( ⇒ | P | leaves) ⇒ | T | ≤ h | L | = h | P | . 3
Another example (range searching) Goal: given a finite point set P ⊂ [0 , 1[ 2 , preprocess P such that, for any query rectangle r ⊆ [0 , 1] 2 , r ∩ P is found in time O ( | r ∩ P | ) . Q: que gagne-t-on par rapport a une r 1 point per leaf ( ⇒ | P | leaves) ⇒ | T | ≤ h | L | = h | P | . Query: go from root to leaves, stopping each time r ∩ � v = ∅ . ⇒ O ( | r ∩ T | ) ≤ O ( h | r ∩ L | ) # of nodes of T that intersect r Bound on h ? Q # of leaves of T that intersect r 3
Various bounds Let P ⊂ [0 , 1[ 2 be finite. Assume wlog diam( P ) = max { d ( p, q | p, q ∈ Lemma P } ≥ 1 / 2 . Then, h = O (log Φ( P )) , where Φ( P ) = diam( P ) / min { d ( p,q ) | p,q ∈ P } . ∀ p, q ∈ P , let h ( p, q ) be the small- Def est i s.t. v i ( p ) � = v i ( q ) . 2 − i ⌊ 2 i p x ⌋ , 2 − i ⌊ 2 i p y ⌋ ` ´ ∀ i , v i ( p ) = ∀ p, q ∈ [0 , 1] 2 , h ( p, q ) = Prop . . min {−⌈ log( p x ∨ q x ) ⌉ , −⌈ log( p y ∨ q y ) ⌉} ≤ min {−⌈ log | p x − q x | , −⌈ log | p y − q y |} = −⌈ log max {| p x − q x | , | p y − q y |}⌉ 1 2 d ( p, q ) ⌉ = 1 ≤ −⌈ log 2 − log d ( p, q ) √ Observation: for every internal node v p (0 . 0111 , 0 . 0101) of T , | � v ∩ P | ≥ 2 q (0 . 1001 , 0 . 0101) ⇒ l ( v ) ≤ h ( p, q ) − 1 , ∀ p, q ∈ � v ⇒ h ≤ 1 2 − log min { d ( p, q ) | p, q ∈ P } ≤ 3 2 + log Φ( P ) 4
Various bounds Let P ⊂ [0 , 1[ 2 be finite. Assume wlog diam( P ) = max { d ( p, q | p, q ∈ Lemma P } ≥ 1 / 2 . Then, h = O (log Φ( P )) , where Φ( P ) = diam( P ) / min { d ( p,q ) | p,q ∈ P } . Corollary data structure size: O ( | P | log Φ( P )) construction time: O ( | P | log Φ( P )) query time: O (log log Φ( P )) Can we do better? Q p (0 . 0111 , 0 . 0101) q (0 . 1001 , 0 . 0101) 4
Compressed quadtrees Bounds on complexity depend on Φ( P ) . Pb 5
Compressed quadtrees Bounds on complexity depend on Φ( P ) . Pb 5
Compressed quadtrees ATTENTION: encode level in each node every internal node has ≥ 2 sons ⇒ | T | ≤ 2 | L | − 1 = 2 | P | − 1 how to construct T efficiently? Q how to locate a point efficiently? Q 5
Compressed quadtrees ATTENTION: encode level in each node every internal node has ≥ 2 sons ⇒ | T | ≤ 2 | L | − 1 = 2 | P | − 1 how to construct T efficiently? Q how to locate a point efficiently? Q Since some nodes are missing along the path 5
Compressed quadtrees (construction) Computing the uncompressed quadtree can take unbounded time Note Quadratic algorithm: 1. For all pairs of points ( p, q ) ∈ P 2 , find � v pq = � v i ( p ) = � v i ( q ) , where i = h ( p, q ) − 1 . → v pq must be a node of compressed quadtree T → every node of T is a v pq for some pair ( p, q ) ∈ P 2 ⇒ this step computes the exact list of the nodes of T 2. For each node v in the list, find its most recent ancestor (in the list) and connect v to it. a node is stored only once in the list, although it may have Note been found multiple times in step 1 (use hash-table). 6
Compressed quadtrees (construction) More subtle algorithm: let k = | P | / 10 . 7
Compressed quadtrees (construction) let k = | P | / 10 . - Compute D r s.t. More subtle algorithm: r opt ( P, k ) ≤ r ≤ 2 r opt ( P, k ) . 7
Compressed quadtrees (construction) let k = | P | / 10 . - Compute D r s.t. More subtle algorithm: r opt ( P, k ) ≤ r ≤ 2 r opt ( P, k ) . - Let l = 2 ⌊ log r ⌋ ≥ r / 2 . Place the pts of P on UG l , and find cell c with max number of points. P in = P ∩ c , P out = P \ c . 25 = | P | l ≥ r k 2 ⇒ | P in | ≥ 250 . | D r ∩ P | ≥ k , and D r intersects at l ≤ 2 r opt ( P, k ) ⇒ | P in | ≤ 4 | P | 5 . No disk of radius l 2 ≤ r opt ( P, k ) contain 7
Compressed quadtrees (construction) let k = | P | / 10 . - Compute D r s.t. More subtle algorithm: r opt ( P, k ) ≤ r ≤ 2 r opt ( P, k ) . - Let l = 2 ⌊ log r ⌋ ≥ r / 2 . Place the pts of P on UG l , and find cell c with max number of points. P in = P ∩ c , P out = P \ c . 25 = | P | l ≥ r k 2 ⇒ | P in | ≥ 250 . | D r ∩ P | ≥ k , and D r intersects at l ≤ 2 r opt ( P, k ) ⇒ | P in | ≤ 4 | P | 5 . No disk of radius l 2 ≤ r opt ( P, k ) contain - Recursive call on P in and P out . 7
Recommend
More recommend