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. But its parent is the root, and it is full. We will need to split the root. Order 3 B-Tree Insertion Example 2

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. The root has room, so we add 57 and are done. This concludes the insertion of 60. Order 4 B-Tree Insertion Example 1

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 4th 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 B Tree Insertion (name)‏
Next we'll try some examples using names instead of numbers. We will start with this order 4 B-Tree. Let's add [Shaffer, Clifford] to this tree. Order 4 B-Tree Insertion Example 5

12 B Tree Insertion (name)‏
Using alphabetical comparison of last names, we start from the root: [Shaffer, Clifford] > [Dumais, Susan] so we follow the first link. The right leaf has room, so [Shaffer, Clifford] is added and we are done. Order 4 B-Tree Insertion Example 5

13 B Tree Insertion (name)‏
Here, we add [Platt, Jenny]. From the root, [Platt, Jenny] > [Dumais, Susan], so we go to the second leaf. Since the last name Platt is already in the tree, we add [Platt, Jenny] after [Platt, John]. Order 4 B-Tree Insertion Example 6

14 B Tree Insertion (name)‏
Next, we try to add [Chen, Jian]. From the root, since [Chen, Jian] < [Dumais, Susan], we follow the left link to the first leaf. Since this leaf is full, we will have to perform a split. Order 4 B-Tree Insertion Example 7

15 B Tree Insertion (name)‏
We will split the node around [Chen, Ming]. Order 4 B-Tree Insertion Example 7

16 B Tree Insertion (name)‏
Since there is room in the root, [Chen, Ming] is added to the root. This completes the insertion. Order 4 B-Tree Insertion Example 7

17 B Tree Insertion (name)‏
For one more insertion, we'll add [Chen, Xiao]. From the root, since the last name Chen is already in the root, we'll add [Chen, Xiao] after [Chen, Ming]. This means we will follow the middle link. Order 4 B-Tree Insertion Example 8

18 B Tree Insertion (name)‏
Since the middle leaf already has the last name Chen, we will add [Chen, Xiao] after [Chen, Zheng] and we are done. Order 4 B-Tree Insertion Example 8


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