Presentation is loading. Please wait.

Presentation is loading. Please wait.

B-Tree of degree 3 t=3 data internal nodes

Similar presentations


Presentation on theme: "B-Tree of degree 3 t=3 data internal nodes"— Presentation transcript:

1 B-Tree of degree 3 t=3 data internal nodes 40 80 10 27 31 52 65 88 96
28 30 45 50 70 74 77 82 84 97 99 15 25 33 35 53 55 58 60 62 90 92 94 data

2 For simplicity, assume each key links to some associated data
40 80 10 27 31 52 65 88 96 3 7 45 50 15 25 82 84 97 99 53 55 58 60 62 28 30 33 35 70 74 77 90 92 94 6/9/2019 IT 279

3 Bt is a B-tree with minimum degree t (or order m , where m = 2t):
The root has n keys with 1  n  2t-1 Each non-root node has n keys with t-1  n  2t-1 Each non-leaf node with n keys has n+1 children All leaves are of the same height For each node as shown in the following k1 k2 ki ki+1 kn where k1 < k2 < ... < ki < ki+1 < ... < kn 6/9/2019 IT 279

4 Bt is a B-tree with minimum degree t:
and if the node is not a leaf, then k1 k2 ki ki+1 kn C0 C1 C2 Ci Ci+1 Cn-1 Cn ki  min(Ci)  max(Ci)  ki+1, for 1  i  n-1 max(C0)  k1 kn  min(Cn) maximum and minimum keys in Ci 6/9/2019 IT 279

5 Bt is a B-tree with minimum degree t:
Some Terminologies ki ki+1 Ci-1 Ci the left-child of key the right-child of key ki ki We say that a node is full if it has 2t-1 keys If t=2, B2 is known as tree (named after the number of children) 6/9/2019 IT 279

6 Algorithm for inserting a new key (data) into Bt
The new arrived key will be inserted into some leaf Search the leaf with keys that can contain the new key (according to the key values). During the search, if we reach a full node, i.e., it already has 2t-1 keys, then we split the node and repeat 1 and 2 again until the new key is successfully inserted. Note: after splitting a leaf (if necessary), we should have a leaf with room for the new key. 6/9/2019 IT 279

7 Algorithm for splitting a full root
k1 kt-1 kt kt+1 k2t-1 C0 Ct-2 Ct-1 Ct Ct+1 C2t-1 Split  new root kt k1 kt-1 kt+1 k2t-1 C0 Ct-2 Ct-1 Ct Ct+1 C2t-1 6/9/2019 IT 279

8 Algorithm for splitting a full non-root node I. Splitting node
parent node k’ ka ka+1 k’’ link before splitting kt k1 kt-1 kt+1 k2t-1 C0 Ct-2 Ct-1 Ct Ct+1 C2t-1 6/9/2019 IT 279

9 Algorithm for splitting a full non-root node II. Modifying the parent
parent node k’ ka ka+1 k’’ kt k1 kt-1 kt+1 k2t-1 C0 Ct-2 Ct-1 Ct Ct+1 C2t-1 6/9/2019 IT 279

10 Algorithm for splitting a full non-root node II. Modifying the parent
parent node k’ ka kt ka+1 k’’ k1 kt-1 kt+1 k2t-1 C0 Ct-2 Ct-1 Ct Ct+1 C2t-1 6/9/2019 IT 279

11 t=2, B2 : 2-3-4 tree. The root has n keys with 1  n  2t-1
Each non-root node has n keys with t-1  n  2t-1 t=2, B2 : tree. 25 10 20 30 40 25 15 16 20 10 30 40 40 40 20 10 20 30 15 16 10 30 20 10 25 30 40 6/9/2019 IT 279

12 t=2 B2 : 2-3-4 tree. The root has n keys with 1  n  2t-1
Each non-root node has n keys with t-1  n  2t-1 35 t=2 B2 : tree. 20 10 15 16 25 30 40 35 20 30 20 30 10 15 16 25 35 40 10 15 16 25 40 6/9/2019 IT 279

13 t=2, B2 : 2-3-4 tree. The root has n keys with 1  n  2t-1
Each non-root node has n keys with t-1  n  2t-1 t=2, B2 : tree. 5 20 30 10 15 16 25 35 40 5 need to split again 5 20 15 20 30 30 15 10 16 25 35 40 10 16 25 35 40 6/9/2019 IT 279


Download ppt "B-Tree of degree 3 t=3 data internal nodes"

Similar presentations


Ads by Google