9. B-Tree Properties 4. Each leaf node (other than the root node if it is a leaf) must contain at least (m / 2) - 1 keys. Note: x is the ceiling function whose value is the smallest integer that is greater than or equal to x. E.g., 3 = 3 3.34 = 4 1.98 = 2 5.001 = 6
10. B-Tree Properties A B-tree is a fairly well-balanced tree since all leaf nodes must be at the bottom. Recall condition 2. All internal nodes (except perhaps the root node) have at least (m / 2) (nonempty) children keep it bushy and balanced. Causes the tree to fan out , i.e., shorter height
11.
12. Insertion Example Insert the following letters into what is originally an empty B-tree of order 5: C N G A H E K Q M F W L T Z D P R X Y S Order 5 max of 5 children and 4 keys. All nodes (except root) must have a minimum of 2 keys. Inserting in alphabetical order the first 4 letters:
13. Insertion Example Insert H next. No room. Split into 2 nodes. Move median item G up into new root node Insert EKQ next
14. Insertion Example C N G A H E K Q M F W L T Z D P R X Y S Inserting E, K, & Q doesn’t require splits. But inserting M does ?? - split into 2
15. Insertion Example C N G A H E K Q M F W L T Z D P R X Y S F, W, L, and T are then added without needing any split.
16. Insertion Example C N G A H E K Q M F W L T Z D P R X Y S F, W, L, and T are then added without needing any split. Adding Z requires node to split Move median (T) up & split node
25. B Tree Deletion - Delete E next - Very problematic siblings as well as E has no extra keys - Combine the leaf with one of two siblings - Move down parent’s key that was between these two siblings
39. Insert (Leaf and index pages are full) Add 95 belongs here Split leaf page into 2: 75 80 and 85 90 95 Middle key (85) goes up parent is full split parent 25 50 60 75 85 Middle key (60) made a new parent of the parents
41. Rotation When a leaf node is full and its sibling is not. Reduce number of page splits. E.g., add 70 previously, we split the 50 55 60 65 node and brought 60 up Instead, move a record to its sibling: