Download presentation
Presentation is loading. Please wait.
1
Amortized Rigidness in Dynamic Cartesian Trees Iwona Białynicka-Birula and Roberto Grossi Università di Pisa STACS 2006
2
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 2 Cartesian trees Vuillemin 1980 Nodes store points 〈x, y〉 y value can be viewed as priority Recursive definition Root stores point with greatest y value x value partitions remaining points (left and right subtrees)
3
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 3 Cartesian tree example 〈2, 22〉 〈21, 20〉 〈18, 19〉 〈6, 17〉 〈20, 16〉 〈7, 15〉 〈8, 13〉 〈5, 12〉 〈9, 11〉 〈17, 10〉 〈3, 9〉 〈16, 8〉 〈10, 7〉 〈22, 6〉 〈15, 4〉 〈12, 3〉 〈1, 2〉 〈11, 1〉 〈19, 21〉 〈4, 18〉 〈14, 5〉
4
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 4 Applications Priority queue Randomized searching (treaps) Range and dominance searching RMQ (Range Maximum Query) LCA (Least Common Ancestor) Integer sorting Memory management Suffix trees...
5
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 5 From RMQ to LCA 2, 22, 9, 18, 12, 17, 15, 13, 11, 7, 1, 3, 5, 4, 8, 10, 19, 21, 16, 20, 6 22 20 19 17 16 15 13 12 11 10 9 8 7 6 4 3 2 1 21 18 5 9, 18, 12, 17, 15, 13, 11, 7, 1 17 15 13 12 11 9 7 1 18
6
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 6 From LCP array to suffix tree $ I$ IPPI$ ISSIPPI$ ISSISSIPPI$ MISSISSIPPI$ PI$ PPI$ SIPPI$ SISSIPPI$ SSIPPI$ SSISSIPPI$ 0 1 1 4 0 0 1 0 2 1 3 $ IM...P S $P...SSI P...S... I$PI$ISI P...S... P...S... 1 2 3 4 5 6 7 8 910 11 12 11 8 5 2 1 10 9 7 4 6 3 0114001021301140010213
7
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 7 History Static setting O(n) construction time, provided elements already sorted Randomized Random priority values – treaps O(log n) expected height O(log n) expected update time Other distributions yield O(√n) or even O(n) height (Devroye 1994) Dynamic and deterministic ???
8
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 8 Our result Dynamic Cartesian tree Supports insertion Supports weak deletion Maintains actual tree structure between each operation O(log n) amortized time per operation
9
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 9 Solution outline Combinatorial analysis How many tree elements change due to n insertions? Notion of entropy is exploited Auxiliary structure for accessing tree Needed to quickly access tree elements which need to change Based on the interval tree
10
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 10 Insertion 〈2, 22〉 〈21, 20〉 〈18, 19〉 〈6, 17〉 〈20, 16〉 〈7, 15〉 〈8, 13〉 〈5, 12〉 〈9, 11〉 〈17, 10〉 〈3, 9〉 〈16, 8〉 〈10, 7〉 〈22, 6〉 〈15, 4〉 〈12, 3〉 〈1, 2〉 〈11, 1〉 〈19, 21〉 〈4, 18〉 〈14, 5〉 〈13, 14〉
11
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 11 Insertion – worst case 〈1, 16〉 〈7, 4〉 〈8, 2〉 〈17, 15〉 〈16, 13〉 〈15, 11〉 〈14, 9〉 〈13, 7〉 〈12, 5〉 〈11, 3〉 〈10, 1〉 〈2, 14〉 〈3, 12〉 〈4, 10〉 〈5, 8〉 〈6, 6〉 〈9, 17〉
12
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 12 Analysis – main idea Inserting new elements does not require comparing y coordinates of existing points In turn, deleting points does Conclusion: insertions reduce tree information content... so information entropy can be used as a potential function in an amortized analysis
13
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 13 > > > > > > > > > > > Insertion revisited
14
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 14 Insertion reversed (deletion) ???????????
15
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 15 Formally... Tree T induces partial order ≺ T on nodes Defined by the heap condition Partial order ≺ T has ℒ(T) linear extensions Linear extensions are permutations satisfying the order, i.e. P[i] ≺ T P[j] ⇒ i < j We define missing entropy: ℋ(T)=log ℒ(T) Information needed to sort nodes given tree topology > > > > > > > > > A B C D E I G J FH A B H J F G I D E C H A J F G I D B E C A J D F H G I B E C D J I A H F G E B C H J D A F G I E B C A D H F G J I B E C...
16
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 16 Missing entropy Can be zero ℋ(T)=0 Or can be up to ℋ(T)=O(n log n) When an insertion affects k edges, ℋ(T) increases by at least Ω(k)
17
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 17 So what now? Amortized number of edge modifications is O(log n) per insertion into an initially empty tree Node modifications are always constant But how to access the edges to modify? Without increasing the complexity
18
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 18 Implementation overview Companion interval tree stores tree edges Edges in Cartesian tree are either disjoint or nested So the interval tree has additional properties Operations are tailored to the special case of the Cartesian tree
19
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 19 Insertion once again 1. Find parent 2. Edges affected 4. Shrink k 3a. Delete 2 3b. Insert 3 1. Find parent 2. Edges affected 3a. Delete 2 3b. Insert 3 4. Shrink k
20
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 20 Action implementations 1. Find parent Uses the interval tree as a search tree 2. Edges affected Special kind of stabbing query 3. Insert and delete Standard interval tree operations 4. Shrink Emulating using inserts and deletes would yield O(k∗log n) Amortized argument based on the fact that shrinking edge travels down O(log n) O(log n+k) O(1)∗O(log n) k∗O(1)
21
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 21 Summary Scheme for maintaining a Cartesian tree under insertion and week deletion Amortized O(log n) time per update At any moment the actual tree structure is accessible Solution components Combinatorial analysis of tree behavior Auxiliary data structure First result on dynamic Cartesian trees in a non-stochastic setting
22
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 22 Further work Strong deletion Applications For example RMQ
23
23 February 2006 23rd International Symposium on Theoretical Aspects of Computer Science 23 Thank you! Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.