1 / 23

Amortized Rigidness in Dynamic Cartesian Trees

STACS 2006. Amortized Rigidness in Dynamic Cartesian Trees. Iwona Białynicka-Birula and Roberto Grossi Universit à di Pisa. 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

Download Presentation

Amortized Rigidness in Dynamic Cartesian Trees

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. STACS 2006 Amortized Rigidness inDynamic Cartesian Trees Iwona Białynicka-Birula and Roberto GrossiUniversità di Pisa

  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 • xvalue partitions remaining points(left and right subtrees) 23rd International Symposium on Theoretical Aspects of Computer Science

  3. Cartesian tree example 〈2, 22〉 〈19, 21〉 〈21, 20〉 〈18, 19〉 〈4, 18〉 〈6, 17〉 〈20, 16〉 〈7, 15〉 〈8, 13〉 〈5, 12〉 〈9, 11〉 〈17, 10〉 〈3, 9〉 〈16, 8〉 〈10, 7〉 〈22, 6〉 〈14, 5〉 〈15, 4〉 〈12, 3〉 〈1, 2〉 〈11, 1〉 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 • ... 23rd International Symposium on Theoretical Aspects of Computer Science

  5. From RMQ to LCA 22 21 20 19 18 18 17 17 16 15 15 13 13 12 12 11 11 10 9 9 8 7 7 6 5 4 3 2 1 1 2, 22, 9, 18, 12, 17, 15, 13, 11, 7, 1, 3, 5, 4, 8, 10, 19, 21, 16, 20, 6 9, 18, 12, 17, 15, 13, 11, 7, 1 23rd International Symposium on Theoretical Aspects of Computer Science

  6. I M... P $ S 12 1 I$ PI$ I SI $ P... SSI P... S... 10 9 11 8 7 4 P... S... P... S... 6 3 5 2 From LCP array to suffix tree 12 11 8 5 2 1 10 9 7 4 6 3 $ I$ IPPI$ ISSIPPI$ ISSISSIPPI$ MISSISSIPPI$ PI$ PPI$ SIPPI$ SISSIPPI$ SSIPPI$ SSISSIPPI$ 0 1 1 4 0 0 1 0 2 1 3 0 1 1 4 0 0 1 0 2 1 3 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 • ??? 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 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 23rd International Symposium on Theoretical Aspects of Computer Science

  10. Insertion 〈2, 22〉 〈19, 21〉 〈21, 20〉 〈18, 19〉 〈4, 18〉 〈6, 17〉 〈20, 16〉 〈7, 15〉 〈13, 14〉 〈8, 13〉 〈5, 12〉 〈9, 11〉 〈17, 10〉 〈3, 9〉 〈16, 8〉 〈10, 7〉 〈22, 6〉 〈14, 5〉 〈15, 4〉 〈12, 3〉 〈1, 2〉 〈11, 1〉 23rd International Symposium on Theoretical Aspects of Computer Science

  11. Insertion – worst case 〈9, 17〉 〈1, 16〉 〈17, 15〉 〈2, 14〉 〈16, 13〉 〈3, 12〉 〈15, 11〉 〈4, 10〉 〈14, 9〉 〈5, 8〉 〈13, 7〉 〈6, 6〉 〈12, 5〉 〈7, 4〉 〈11, 3〉 〈8, 2〉 〈10, 1〉 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 23rd International Symposium on Theoretical Aspects of Computer Science

  13. Insertion revisited > > > > > > > > > > > 23rd International Symposium on Theoretical Aspects of Computer Science

  14. Insertion reversed (deletion) ? ?? ? ? 23rd International Symposium on Theoretical Aspects of Computer Science

  15. 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 Formally... C > > B E > > > A D I > > J G > > F H 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 . . . 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) 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 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 23rd International Symposium on Theoretical Aspects of Computer Science

  19. Insertion once again • 1. Find parent • 2. Edges affected • 3a. Delete 2 • 3b. Insert 3 • 4. Shrink k 3b. Insert 3 1. Find parent 2. Edges affected 3a. Delete 2 4. Shrink k 23rd International Symposium on Theoretical Aspects of Computer Science

  20. Action implementations • Find parent • Uses the interval tree as a search tree • Edges affected • Special kind of stabbing query • Insert and delete • Standard interval tree operations • 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) 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 23rd International Symposium on Theoretical Aspects of Computer Science

  22. Further work • Strong deletion • Applications • For example RMQ 23rd International Symposium on Theoretical Aspects of Computer Science

  23. Thank you! • Questions? 23rd International Symposium on Theoretical Aspects of Computer Science

More Related