Professional Documents
Culture Documents
It works as long as the entire data structure can fit into the
main memory
When the data size is too large and the data has to reside on
disk, the performance of AVL tree may deteriorate rapidly
CGM T X
AB DE F J KL NO QRS UW Y Z
n+1
Therefore, h ≤ logt 2 .
CGM T X
AB DE F J KL NO QRS UW Y Z
Insert V
P
CGM T X
AB DE F J KL NO QRS UV W Y Z
]
]
]
x
x
x
ke 1 [
ke 1 [
1[
ke x]
]
x
i−
i−
i+
i[
i[
y
y
y
y
y
ke
ke
x GM x GKM
y = ci [x] y = ci [x] z = ci+1 [x]
J KL J L
T1 T2 T3 T4 T1 T2 T3 T4
Question
How can we assure that the parent of a full node is not full?
Answer
Split each full node along the path from the root to the leaf where
the new key will be inserted
CGM T X
AB DE F J KL NO QRS UW Y Z
GP
C M T X
AB DE F J KL NO QRS UW Y Z
(b) insert H: split the encountered full node
C KM T X
AB DE F J L NO QRS UW Y Z
GP
C KM T X
AB DE F HJ L NO QRS UW Y Z
(d) insert H: insert into an existing nonfull leaf node
CGM T X
AB DE F J KL NO QRS UW Y Z
Delete E
P
CGM T X
AB DF J KL NO QRS UW Y Z
Question
How can we delete a key in one downward pass without “back up”?
Answer
Invariant: when the key is deleted from the subtree rooted at x,
the number of keys in x is at least the minimum degree t.
CGM T X
AB DF J KL NO QRS UW Y Z
Delete G
P
CF M T X
AB D J KL NO QRS UW Y Z
CF M T X
AB D J KL NO QRS UW Y Z
Delete F
P
CJ M T X
AB D KL NO QRS UW Y Z
CJ M T X
AB D K NO QRS UW Y Z
Delete J
P
CM T X
AB DK NO QRS UW Y Z
CM T X
B DK NO QRS UW Y Z
Delete B
P
DM T X
C K NO QRS UW Y Z
DM T X
C K NO QRS UW Y Z
Delete C
P
M T X
DK NO QRS UW Y Z