150 likes | 344 Views
An Optimal Dynamic Interval Stabbing-Max Data Structure?. Pankaj K. Agarwal, Lars Arge and Ke Yi Department of Computer Science Duke University. 3. 4. 2. 1. 5. q. Problem Definition. S : n intervals in 1D w ( s ) : weight of s S ; w ( s ) R
E N D
An Optimal Dynamic Interval Stabbing-Max Data Structure? Pankaj K. Agarwal, Lars Arge and Ke Yi Department of Computer Science Duke University
3 4 2 1 5 q Problem Definition • S : n intervals in 1D • w(s): weight of sS; w(s)R • Stabbing-max query qR: max{w(s) | sS, qs} • Three operations: • Query • Insert an interval • Delete an interval
Previous Results • Trivial if no deletions • A binary search tree: O(n) space, O(log n) query & insert • Interval tree • Size: O(n) • Query: O(log2n) • Insert: O(log n) • Delete: O(log n) • Kaplan, Molad and Tarjan [STOC’03] • The best known result • Size: O(n) • Query: O(log n) • Insert: O(log n) • Delete: O(log n loglog n) q 4 4 3 2 4 3 1
Our Results • Trivial if no deletions • A binary search tree: O(n) space, O(log n) query & insert • Interval tree • Size: O(n) • Query: O(log2n) • Insert: O(log n) • Delete: O(log n) • Kaplan, Molad and Tarjan [STOC’03] • The best known result • Size: O(n) • Query: O(log n) • Insert: O(log n) • Delete: O(log n loglog n) q 4 4 3 2 4 3 1
Base Tree T • Main idea: use a base interval tree with fan-out f = • Height of tree: O(log n / loglog n) • Each leaf stores Q(log n) endpoints • O(n / log3/2n) internal nodes, O(n / log n) nodes in total O( ) slabs slab slab multislab multislab multislab O(log n) multislabs
Base Tree T v S(v): Intervals associated with nodev Each interval is broken into a left, a right and a middle segment
Middle Segments: Overview • A secondary structure Mv for each internal node v of the base tree • Answers query within S(v) in O(loglog n) time • O(log n / loglog n) nodes on the path • O(log n) time in total • Insert or delete a segment in O(log n) time • Only one Mvis affected • Total time: O(log n) • Size: O(|S(v)| + log3/2n) • O(n / log3/2n) internal nodes • Total size: O(n) S(v)
Secondary Structure Mv • Build a multislab heap for each multislab • Stores all segments spanning exactly this multislab • Build a slab heap for each slab • Stores the top elements of the relevant multislab heaps • Query: O(loglog n) • Find the slab heap • Update: O(log n) • Update the multislab heap: O(log n) • Update the slab heaps: 1 2 3 4 5 1 2 3 4 5 Size: O(log3/2n) 2-4 2-5 3-3 4-5 1-2 Size: O(|S(v)|)
Left Segments: A Static Structure • L(v) : segments in iS(ui) with left endpoints in the slab of v • Basic idea: answer query inL(v) − L(w4) when visiting v • f(wj) : maximum interval inL(v) with left endpoint in the slab of wj • Organize in a tournament tree • Can find the maximumof the red segmentsin time O(loglog n) • Total: O(log n) q f(w2) u2 u1 v w1w2w3w4 w5 f(w1) f(w2) f(w3) f(w4)
Updating f • Each segment at u2 affects the f values at O(log n / loglog n) descendents • Each f can be updatedin O(loglog n) time (using additional structures) • Total update time: O(log n) • Other issues (omitted) • Rebalancing of the base tree u2 u1 v w1w2w3w4 w5
Is It Really Optimal? • Is the O(log n) deletion bound really optimal? • The O(log n) query bound is optimal in comparison model • Can show O(log n) query → W(log n) insert • O(log n) query & insert → W(log n) delete ? • Probably yes • Errata (Theorem 4.2 & 4.3) • Query & update time: • O(logd-1n) → O(logdn)
Putting Everything Together y(u, v) = max{y(u, w), for all of v’s children w} f(w) = max{y(u, w), for all v’s ancestors u execpt p(w)} Ta Base tree y(a,b) a y(a,c) y(a,d) y(a,e) b Tb c d y(b,d) y(b,c) Consider f(e) y(b,e) y(b,f) y(b,g) f g Td e h i j Tc y(d,e) y(c,e) y(c,f) y(c,g) y(d,f) y(d,g)
Putting Everything Together Update: O(log n / loglog n· loglog n) = O(log n) Only one Tv is affected Ta Base tree y(a,b) a y(a,c) y(a,d) y(a,e) b Tb c d Total size is still linear y(b,d) y(b,c) y(b,e) f g Td e h i j Tc y(d,e) y(c,e)