Adding Range Restriction Capability to Dynamic Data Structure - PowerPoint PPT Presentation

About This Presentation
Title:

Adding Range Restriction Capability to Dynamic Data Structure

Description:

Adding Range Restriction Capability to Dynamic Data Structure ... capability the complexity of which is described by the primed functions below. ... – PowerPoint PPT presentation

Number of Views:102
Avg rating:3.0/5.0
Slides: 33
Provided by: ohad
Category:

less

Transcript and Presenter's Notes

Title: Adding Range Restriction Capability to Dynamic Data Structure


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 a balanced if ?(x) a, 1 a.
  • Binary Search Tree is said to be Bounded Balanced
    Tree with parameter a, or BB(a), if all nodes in
    the tree are a balanced.
  • The height of BB(a) for some positive a 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) lt a Let y be the right child of
x if ?(y) lt ? 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
  • U(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
  • U(n) U(n)log(n).
  • S(n) S(n)log(n).
  • Q(n) Q(n)log(n).

7
Augmented Bounded Balance Tree
  • BB(a) 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 its 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(a) 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 a lt there exist ? and
    a, with a lt a that make the following true.
  • Let T be a sub tree, rooted at a node x,in which
    all nodes are a balanced.
  • Suppose that x is not a 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 a
    balanced.

12
Balance After Rotation
Upper Bound Lower Bound Value Variable Rotation Type
Single

Double


13

0.72500 0.05249 0.05000
0.70000 0.10989 0.10000
0.67500 0.17191 0.15000
0.65000 0.23805 0.20000
0.60961 0.28077 0.25000
14
  • ß(x) 2 max(0, ?(x)(1a),a?(x)).
  • Node is a balanced ß(x) 0.
  • Node is a balanced ß(x) 2.

15
  • INSERT(w,T)
  • Insert node w into T according to its 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) gt 2 then
  • PANIC begin
  • let x be the highest node with
    ß(x) gt 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) gt 1
  • ROTATE(X)
  • end

16
  • 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

17
  • 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 U(n), where n is
    the maximum number of records ever presents. Then
    the amortized complexity U(n) for INSERT and
    DELETE is O(U(n)log(n)).

18
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 U(n) for the resulting structure
    could be O(U(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.

19
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.

20
  • Disunified node - node that its auxiliary field
    is not fully rebuild.
  • Unified node - node that its 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)

21
  • 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.

22
  • 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.

23
  • 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.

24
  • INSERTB(w,T)
  • Insert node w into T according to its 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) gt 2 then
  • PANICB(x)
  • for each node x on the path from w to the root
  • DoFIXUP(x)
  • if x is eligible and ß(x) gt 1
  • ROTATEB(X)
  • end

25
  • PanicB(x)
  • begin
  • let x be the highest node with ß(x) gt 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

26
  • 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

27
Several Problems
  • Since now ß(x) can be gt 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.

28
  • 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.

29
  • 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.

30
  • 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).

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

32
  • 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).
Write a Comment
User Comments (0)
About PowerShow.com