BB[α] tree — definition

BB[α] tree — definition
Let size(v ) be the number of nodes in the subtree of v .
A node v is of bounded balance α if
size(v .left) ≥ bα·size(v )c and size(v .right) ≥ bα·size(v )c
A BB[α] tree (α < 0.5) is a binary search tree such that
every node v is of bounded balance α
The height of a BB[α] tree with n nodes is at most
log1/(1−α) n.
9 12
5
8
3
4
1
2
3
16
1
10
1
6
1
14
α = 1/3
1
20
Insertion
To insert an element to a BB[α] tree, insert it as a new
leaf. Let v be the highest node that is not of bounded
balance α. If v exists, replace the subtree of v by a
balanced tree containing the same elements.
The time complexity is Θ(log n + size(v )), which is Θ(n)
in the worst case.
9 12
5
8
3
4
1
2
3
16
1
10
1
6
1
14
α = 1/3
1
20
Insertion
To insert an element to a BB[α] tree, insert it as a new
leaf. Let v be the highest node that is not of bounded
balance α. If v exists, replace the subtree of v by a
balanced tree containing the same elements.
The time complexity is Θ(log n + size(v )), which is Θ(n)
in the worst case.
10 12
6
v 8
4
1
10
4
2
1
6
2
3
3
16
1
14
α = 1/3
1
20
Insertion
To insert an element to a BB[α] tree, insert it as a new
leaf. Let v be the highest node that is not of bounded
balance α. If v exists, replace the subtree of v by a
balanced tree containing the same elements.
The time complexity is Θ(log n + size(v )), which is Θ(n)
in the worst case.
10 12
6
6
3
3
1
2
3
16
2
8
1
4
1
14
1
10
α = 1/3
1
20
Amortized complexity
The actual cost of an insert operation is
depth(u) + size(w ), where u is the new leaf, and w is the
node whose subtree was replaced (depth(u) is the depth
after the first stage).
Claim
The amortized cost of insert is 1 +
1
1−2α
log1/(1−α) n + O(1).
Let ∆v = |size(v .left) − size(v .right)|.
We keep the following invariant: Every node v with
1
∆v ≥ 2 stores 1−2α
∆v dollars.
For the first stage of an insert operation, we use at most
log1/(1−α) n charged dollars to pay for the cost depth(u).
1
We also put 1−2α
dollars in each node v whose ∆v value
1
increased. This uses at most 1−2α
log1/(1−α) n charged
dollars.
Amortized complexity
The figure below shows the ∆v values. Each node with
∆v ≥ 2 stores 3∆v dollars.
2 12
2
8
0
4
0
2
0
16
0
10
0
6
0
14
α = 1/3
0
20
Amortized complexity
The figure below shows the ∆v values. Each node with
∆v ≥ 2 stores 3∆v dollars.
After the insertion, we need to add 3 dollars to the root and to
the left child of the root.
3 12
0
16
3
8
0
10
1
4
1
2
0
6
3
0
14
α = 1/3
0
20
Amortized complexity
To pay for the second stage of an insert operation, we use
the dollars stored in w if size(w ) ≥ 1/(1 − 2α)
(if size(w ) < 1/(1 − 2α) we use the charged dollars).
Since w is not of bounded balance α after the first stage,
either
size(w .left) ≤ bα · size(w )c − 1 ≤ α · size(w ) − 1
size(w .right) ≥ size(w ) − (α · size(w ) − 1) − 1
or vice versa.
Thus,
∆w ≥ (1 − 2α) · size(w ) + 1 ≥ 2
so w contains at least size(w ) −
dollars.
1
1−2α
= size(w ) − O(1)