1 / 32

Adding Range Restriction Capability to Dynamic Data Structure

Adding Range Restriction Capability to Dynamic Data Structure. Ohad Shacham Jan 2002. Based on work by Dan E. Willard And George S. Lueker. Agenda. Background – decomposable searching problems, range restriction. Bounded balanced trees.

barney
Télécharger la présentation

Adding Range Restriction Capability to Dynamic Data Structure

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. Adding Range Restriction Capability to Dynamic Data Structure • Ohad Shacham • Jan 2002 Based on work by Dan E. Willard And George S. Lueker

  2. Agenda • Background – decomposable searching problems, range restriction. • Bounded balanced trees. • Adding range restriction capability to dynamic data structure that gives amortized update time but does not guarantee worst case update time. • Comparison of some types of balanced trees. • Modify the range restriction transformation as to guarantee worst case time for each operation.

  3. Background • Decomposable searching problems:A searching problem is decomposable if the response to a query asking the relation of new object ‘x’ to set F can be written as Q(x,F) = q(x,f), f F where is a commutative associative operator. • Range restriction: constraint a query to a specific group of records according to their range component.

  4. Bounded Balanced Trees • Rank of node x, written rank(x) is 1 + #(Nodes that descend from x). • Balance of node x, written ρ(x) is the ratio of rank of the left child of x to rank(x). • Node x is α balanced if ρ(x) [α, 1 –α]. • Binary Search Tree is said to be Bounded Balanced Tree with parameter α, or BB(α), if all nodes in the tree are α balanced. • The height of BB(α) for some positive α is O(logn).

  5. Single rotation X: X: Y: Y: X: X: Double rotation Y: Y: Z: Z: Balance(x); Without loss of generality assume ρ(x) < α; Let y be the right child of x; if ρ(y) < γ Perform the single rotation; else Perform the double rotation;

  6. Adding Range Restriction Capability With Good Total Update Time. Given dynamic data structure D with complexity measures: • Ū(n) - amortized update time. • S(n) - space complexity. • Q(n) - worst case query time. We can produce a corresponding data structure D’ with range restriction capabilities with complexity measures: • Ū’(n) = Ū(n)log(n). • S’(n) = S(n)log(n). • Q’(n) = Q(n)log(n).

  7. Augmented Bounded Balance Tree • BB(α) tree which records stores at leaves only. • The records arrange according to their range component. • Each internal node will have precisely two children.

  8. Each internal node contains: • field telling the largest leaf in it’s left sub tree. • field AUX that points to an instance of the original data structure Containing all records that correspond to leaves descending it. • The BB(α) tree with the auxiliary fields call Augmented tree.

  9. Query with range restriction • Performing a query on all the records whose range component between l and u. Query(l,u,q,T) R the set of nodes whose span is in [l,u] and whose parent span is not; Query the sum, under over all r R, of the response of AUX(r) to query q;

  10. Space and Query Complexities • The time for an execution of Query is O(Q(n)logn) – R contain O(logn) nodes. • The space complexity of augmented trees is O(S(n)logn) – The records in the auxiliary fields are disjoint.

  11. Update the augmented tree • For any positive α < there exist γ and α’, with α’ < α that make the following true. Let T be a sub tree, rooted at a node x,in which all nodes are α’ balanced. Suppose that x is not αbalanced. Then after the call to BALANCE(x), all nodes in T that actively participated (the squares from the last figure) in the rebalancing will be αbalanced.

  12. Balance After Rotation

  13. β(x) = 2 max(0, ρ(x)–(1–α),α–ρ(x)). • Node is αbalanced β(x) = 0. • Node is α’ balanced β(x) ≤ 2.

  14. INSERT(w,T) Insert node w into T according to it’s range component; Set the AUX field of the newly created parent of w to the copy of the AUX field of the sibling of w; for each ancestor x of w insert the record represented by w into AUX(x); if any node x on the path from w to the root has β(x) > 2 then PANIC: begin let x be the highest node with β(x) > 2; rebuilt the tree rooted at x into a BB(1/3) tree; rebuilt all the auxiliary structures in the tree rooted at x; end for each node x on the path from w to the root if β(x) > 1 ROTATE(X); end

  15. ROTATE(x) BALANCE(X); for each node y whose set of descendant has been changed by this call to BALANCE AUX(y) = an instance of data structure D representing the records descending from y; end

  16. There exist a constant ξ such that if a deletion or insertion is made in a tree and no rebalancing is done,then for each node in the tree the change in β(x)rank(x) is bounded above by ξ. • For instance 2 . • Suppose that the amortized complexity for insertions and deletions in D is Ū(n), where n is the maximum number of records ever presents. Then the amortized complexity Ū’(n) for INSERT and DELETE is O(Ū(n)log(n)).

  17. Comparison of Some Types of Balanced Trees • If a procedure analogous to INSERT is implemented using AVL trees, 2-3 trees or conventional bounded balanced trees, then the amortized complexity Ū’(n) for the resulting structure could be Ω(Ū(n)n). • The Reason for this is the number of rebalancing operation which causes many updates of the Auxiliary fields. • The Solution is to define various degrees of balance thus guarantee that when node was rebalanced it became sufficiently well balance that it did not need to be rebalanced again for a while.

  18. Adding Range Restriction Capability With Good Total Update Time. • Main idea: Update the auxiliary field after rebalancing a little bit at a time during a sequence of several operations, instead of rebalancing all at once.

  19. Disunified node - node that it’s auxiliary field is not fully rebuild. • Unified node - node that it’s auxiliary field is fully rebuild. • Partial augmented tree - augmented tree with disunified nodes. • Semi augmented tree - partial augmented tree that every disunified node in the tree has both children unified. (Our tree)

  20. Near descendant of node x - node x, children, grand children and great grandchildren. • Eligible for rotation – node x is eligible for rotation if all of his near descendent are unified.

  21. For each node we add the following field: • FLAG – Boolean flag that equals true if the node is disunified, and false otherwise. • L – A list of records that are represented in the auxiliary field. • The Space complexity remains the same. • The Query worst case time remains the same.

  22. Procedure that add one new element to the auxiliary field: FIXUP(y) let y’ and y’’ be the children of y; z an element of L(y’) U L(y’’) – L(y); add z to the data structure AUX(y); add z to L(y); if L(y’) U L(y’’) – L(y) = then FLAG(y) := false; • There is an implementation of FIXUP that runs in time bounded by O(1) + time for a single insertion in D. • Add DIFL and DIFR pointers for each internal node.

  23. INSERTB(w,T) Insert node w into T according to it’s range component; Set the AUX field of the newly created parent of w to the copy of the AUX field of the sibling of w; Set the L field of the newly created parent of w to the copy of the L field of the sibling of w; for each ancestor x of w do begin insert the record represented by w into AUX(x); insert w into L(x); end if any node x on the path from w to the root has β(x) > 2 then PANICB(x); for each node x on the path from w to the root DoFIXUP(x); if x is eligible and β(x) > 1 ROTATEB(X); end

  24. PanicB(x) begin let x be the highest node with β(x) > 2; rebuilt the tree rooted at x into a BB(1/3) tree; rebuilt all the auxiliary structures and the L lists in the tree rooted at x; end DoFIXUP(x) begin do FIXUP operations on the disunified near descendant of x until either x is eligible or c FIXUPs have been done. end

  25. ROTATEB(x) begin BALANCE(x); for each node y whose set of descendants has been changed by this call to BALANCE begin FLAG(y) true; AUX(y) the null structure for D; L(y) ; end

  26. Several Problems • Since now β(x) can be > 1 how can we be sure that until β(x) will reach 2 it will become eligible ? • The rebalancing causes several nodes to become disunified. • The rebalancing moves some nodes toward the root, so that the node x may acquire new near descendents which may not be unified. Solution: choose large enough constant C will overcome these problems, the coming lemmas will prove this.

  27. Update – Complete execution of INSERTB or DELETEB. • t1,t2 – Points in time between successive updates. • Min(x,t1,t2) – The minimum rank x had at any time between t1 to t2. • Max(x,t1,t2) – The maximum rank x had at any time between t1 to t2. • Update involving node v – Insertion or deletion of an descendant of v. • Node v is the focus of a rotation – If it plays the role of the root in the rotation. • Node v is the focus of a PANICB – If it plays the role of the root in the PANICB.

  28. There exists a constant ξ such that if s updates involving node x occur between t1 and t2, then β(x) will increase by no more than ξs/min(x,t1,t2). • Again ξ = 2 . • Suppose that from time t1 to time t2 at most updates involving x occur. Then a node v can be the focus of at most one rotation or PANIC during any period of time between t1 and t2 over which it is a child or grandchild of x.

  29. Suppose that between t1 and t2 node x never actively participates in a rotation or PANIC. Suppose further that at most updates occurred between t1 and t2. Then there can be no more than ten occasions when a child or grandchild of x is the focus of a rotation or PANIC during this time interval. • It is possible to choose C large enough in the algorithm INSERTB and DELETEB to guaranty that these algorithm never apply the PANIC block to a node of rank greater than max(3ξ,9).

  30. Each insertion or deletion can be done employing O(logn) insertions and deletions operations on the auxiliary data structures and O(logn) additional time.

  31. Let D be a dynamic data structure with complexity measures U,Q, and S. Then we may produce a new structure D’ with range restriction capability the complexity of which is described by the primed functions below. U’(n) = O(U(n)logn), Q’(n) = O(Q(n)logn), S’(n) = O(S(n)logn).

More Related