An Optimal Dynamic Interval StabbingMax Data Structure Pankaj
An Optimal Dynamic Interval Stabbing-Max Data Structure? Pankaj K. Agarwal, Lars Arge and Ke Yi Department of Computer Science Duke University
Problem Definition l l l S : n intervals in 1 D w(s) : weight of s S; w(s) R Stabbing-max query q R : max{w(s) | s S, q s} 3 4 2 1 Three operations: • Query • Insert an interval • Delete an interval 5 q 2
Previous Results l Trivial if no deletions l l Interval tree l l l A binary search tree: O(n) space, O(log n) query & insert Size: O(n) Query: O(log 2 n) Insert: O(log n) Delete: O(log n) q 4 4 3 Kaplan, Molad and Tarjan [STOC’ 03] l l l The best known result Size: O(n) Query: O(log n) Insert: O(log n) Delete: O(log n loglog n) 2 4 3 1 3
Our Results l Trivial if no deletions l l Interval tree l l l A binary search tree: O(n) space, O(log n) query & insert Size: O(n) Query: O(log 2 n) Insert: O(log n) Delete: O(log n) q 4 4 3 Kaplan, Molad and Tarjan [STOC’ 03] l l l The best known result Size: O(n) Query: O(log n) Insert: O(log n) Delete: O(log n loglog n) 2 4 3 1 4
Base Tree T l Main idea: use a base interval tree with fan-out f = l l Height of tree: O(log n / loglog n) Each leaf stores Q(log n) endpoints l O(n / log 3/2 n) internal nodes, O(n / log n) nodes in total slab multislab O( multislab ) slabs O(log n) multislabs 5
Base Tree T v S(v): Intervals associated with node v Each interval is broken into a left, a right and a middle segment 6
Middle Segments: Overview l A secondary structure Mv for each internal node v of the base tree l Answers query within S(v) in O(loglog n) time l l l Insert or delete a segment in O(log n) time l S(v) l l O(log n / loglog n) nodes on the path O(log n) time in total Only one Mv is affected Total time: O(log n) Size: O(|S(v)| + log 3/2 n) l l O(n / log 3/2 n) internal nodes Total size: O(n) 7
Secondary Structure Mv l Build a multislab heap for each multislab l l Build a slab heap for each slab l l l 1 Size: O(log 3/2 n) 2 2 Find the slab heap Update: O(log n) l 1 Stores the top elements of the relevant multislab heaps Query: O(loglog n) l l Stores all segments spanning exactly this multislab 1 -2 Update the multislab heap: O(log n) Update the slab heaps: 2 -4 3 2 -5 4 3 -3 5 5 4 -5 Size: O(|S(v)|) 8
Left Segments: A Static Structure l l L(v) : segments in i. S(ui) with left endpoints in the slab of v q f(w Basic idea: answer query in 2) L(v) − L(w 4) when visiting v f(wj) : maximum interval in u 1 v L(v) with left endpoint in the slab of wj Organize in a tournament tree l Can find the maximum of the red segments w 1 w 2 w 3 w 4 w 5 in time O(loglog n) f(w 1) f(w 2) f(w 3) f(w 4) l Total: O(log n) u 2 9
Updating f l l Each segment at u 2 affects the f values at O(log n / loglog n) descendents Each f can be updated in O(loglog n) time (using additional structures) Total update time: O(log n) Other issues (omitted) l Rebalancing of the base tree w 1 w 2 u 1 v w 3 w 4 w 5 10
Is It Really Optimal? l Is the O(log n) deletion bound really optimal? l l 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 ? l Probably yes Errata (Theorem 4. 2 & 4. 3) l Query & update time: l O(logd-1 n) → O(logdn) 11
Thank you!
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) y(a, c) a y(a, d) y(a, e) y(b, c) Tb b c y(b, d) d Consider f(e) y(b, f)y(b, g) y(c, e) Td Tc e f g h i j y(d, e) 13 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) Ta Only one Tv is affected Base tree y(a, b) y(a, c) a y(a, d) y(a, e) y(b, c) Tb b y(b, d) Total size is still linear c d y(b, e) Td Tc y(c, e) e f g h i j y(d, e) 14
- Slides: 14