1 / 13

Weight balance trees (Nievergelt & Reingold 73)

Weight balance trees (Nievergelt & Reingold 73). Definition. A binary tree. Define the balance at an internal node v to be. where s(v) = #(leaf descendants of v). Tree T is of bounded balance α if for every v, α ≤ ρ (v) ≤ 1- α. ¼ < α ≤ 1- ( √ 2/2) = 0.2928.

kisha
Download Presentation

Weight balance trees (Nievergelt & Reingold 73)

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. Weight balance trees(Nievergelt & Reingold 73)

  2. Definition A binary tree. Define the balance at an internal node v to be where s(v) = #(leaf descendants of v) Tree T is of bounded balance α if for every v, α ≤ ρ(v) ≤ 1- α ¼ < α ≤ 1- (√2/2) = 0.2928..

  3. Weight balance trees - example 5/14 2/5 ½ ⅔

  4. Obvious properties The depth is O(log n) As we go from a node to a child the # of leaves under us decrease by a fraction smaller than (1-α) ≤ w ≤ (1-α) w

  5. 5/14 2/5 ½ ⅔ Updates Nodes on the path to the point where we update may go out of balance

  6. Updates (Cont.) 5/14 6/14 ⅓ 2/5 ¾ ½ ⅔ ⅓ ½

  7. ρ1 γ2 = ρ1 + ρ2 (1- ρ1) Use rotations γ1= ρ1 + ρ2 (1- ρ1) ρ1 y x <===> A ρ2 x C y B C A B a+b = ρ1 (a + b + c) + ρ2 (b + c) = ρ1 (a + b + c) + ρ2 ((a + b + c) - a) = ρ1 (a + b + c) + ρ2 ((a + b + c) - ρ1 (a + b + c) ) = (ρ1 + ρ2 (1- ρ1) ) (a + b + c)

  8. ρ1 γ2 = ρ1 + ρ3ρ2 (1- ρ1) ρ2 (1- ρ3) γ3 = 1 - ρ3ρ2 And double rotations γ1= ρ1 + ρ3ρ2 (1- ρ1) ρ1 z x <===> ρ2 A y x y ρ3 z D A B C D C B

  9. (insertion into right subtree of v) or • (deletion from the left subtree of v) The rebalancing lemma (Blum & Mehlhorn) • Let v be a node such that • ρ(u)  (α, 1- α] for every descendant u of v • ρ(v) < α and Let ρ2 be the balance of vr There are constants d  (α, 1- α] and δ (> 0 if α < 1- (√2/2) ) such that • If ρ2 ≤ d a rotation rebalances the tree, i.e. γ1, γ2  ((1+ δ )α, 1- (1+ δ )α] • If ρ2 > d a double rotation rebalances the tree, i.e. γ1, γ2 , γ3 ((1+ δ )α, 1- (1+ δ )α]

  10. We will not prove the rebalancing lemma, its technical, you are encouraged to look at the proof… Here is what distinguishes BB(α) trees

  11. What is special about BB(α) trees ? Thm: Suppose we carry out a sequence of m updates on a tree of size at most n at any time (starting for the empty tree). Then even if a rotation at a node v takes O(s(v)) time, the total cost of all rotations over the sequence is O( m log n)). Proof.

  12. ρ(v) w + b w + b - a Let w = s(v) when a rotation occurs at v (v goes out of balance) We show that the number of updates through v since the last rotation v was involved in, is at least δαw Suppose ρ(v) ≤ α Assume a insertions and b deletions happened through v since last rotation Then a insertions, b deletions v v  ρ’(v) ≤ A B B’ A’

  13. ρ(v) w + b α w + b w – a + b w - a + b ρ’(v) ≤ (1+δ)α≤ (1+δ)α (w - a + b) ≤ α w + b δα w ≤ (1+δ)αa + (1 - (1+δ)α ) b ≤ a + b

More Related