Presentation is loading. Please wait.

Presentation is loading. Please wait.

B Tree Insertion (ID)‏ Suppose we want to insert 60 into this order 3 B-Tree Starting at the root: 10 < 60 < 88, so we look to the middle child. Since.

Similar presentations


Presentation on theme: "B Tree Insertion (ID)‏ Suppose we want to insert 60 into this order 3 B-Tree Starting at the root: 10 < 60 < 88, so we look to the middle child. Since."— Presentation transcript:

1 B Tree Insertion (ID)‏ Suppose we want to insert 60 into this order 3 B-Tree Starting at the root: 10 < 60 < 88, so we look to the middle child. Since this is a leaf and there is room, we simply add 60. Order 3 B-Tree Insertion Example 1

2 B Tree Insertion (ID)‏ Now we will insert 66 Starting at the root: 10 < 66 < 88, so we look to the middle child. But this leaf is full. We will need to split the leaf node around 60 and try to add 60 to the leaf's parent. Order 3 B-Tree Insertion Example 2 But its parent is the root, and it is full. We will need to split the root.

3 B Tree Insertion (ID)‏ Since the root is full, we will split it around 60. The node with 60 is now the root. This concludes the insertion of 66. Order 3 B-Tree Insertion Example 2

4 B Tree Insertion (ID)‏ Now we will insert 21 into the tree Starting at the root: 21 < 60, so we follow the first link to 10. Since 10 < 21, we then follow the second link to the leaf with 57. There is room in the leaf, so we add 21 and are done. Order 3 B-Tree Insertion Example 3

5 B Tree Insertion (ID)‏ Now we will insert 98 From the root, 60 < 98, so we follow the second link to 88. Since 88 < 98, we then follow the second link to the leaf with 97. There is room in the leaf, so we add 97 and are done. Order 3 B-Tree Insertion Example 4

6 B Tree Insertion (ID)‏ Now we will perform the same insertions for an order 4 B-Tree with the same values. We start by trying to insert 60. Since 60 < 88, we follow the left link. This leaf is already full, so will need to perform a split. Order 4 B-Tree Insertion Example 1

7 B Tree Insertion (ID)‏ We will split the node around 57. Then try to add 57 to its parent. In this case, the parent is the root. Order 4 B-Tree Insertion Example 1 The root has room, so we add 57 and are done. This concludes the insertion of 60.

8 B Tree Insertion (ID)‏ Now we will insert 66 From the root, 57 < 66 < 88, so we follow the middle link. There is room in this leaf, so add 66 and we are done. Order 4 B-Tree Insertion Example 2

9 B Tree Insertion (ID)‏ Next we will insert 21 From the root, 21 < 57, so we follow the first link. Since this is a 4 th order tree, there is room in this leaf. We add 21 and we are done. Order 4 B-Tree Insertion Example 3

10 B Tree Insertion (ID)‏ Now we insert 98 From the root, 57 < 98, so we follow the rightmost link. There is room in this leaf, so we add 98 and we are done. Order 4 B-Tree Insertion Example 4

11 Name insertion examples to be corrected soon Note: the rule in the specs say when duplicate last names are present, the incoming record is to be added after the last record matching the last name. Examples regarding name insertion have been removed and will be revised ASAP  The previous post considered first names, which it shouldn’t for project 3


Download ppt "B Tree Insertion (ID)‏ Suppose we want to insert 60 into this order 3 B-Tree Starting at the root: 10 < 60 < 88, so we look to the middle child. Since."

Similar presentations


Ads by Google