Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
2: B+ Tree
Root
Index Entries
Data Entries
Example B+ Tree
Search begins at root, and key comparisons direct it to a leaf. Search for
5* 19* , all data entries >= 24* ...
13 17 24 30
2*
3*
5*
7*
14* 16*
Insertion in a B+ Tree
Insert (K, P) Find leaf where K belongs, insert If no overflow (2t keys or less), halt. If overflow (2t+1 keys), split node, insert in parent:
(K3
K1 P1 P2 K2 P3 K3 P4 K4 P5 K5 p6 K1 P1 K2 P2 P3 K4 P4
) to parent
K5 P5 p6
If leaf, keep K3 too in right node When root splits, new root has 1 key only
Insertion in a B+ Tree
Bc ca cy t=2 Insert K=19
80
20
60
100
120
140
10
15
18
20
30
40
50
60
65
80
8 5
90
10
15
18
20
30
40
50
60
65
80
85
90
Insertion in a B+ Tree
After insertion
80
20
60
100
120
140
10
15
18
19
20
30
40
50
60
65
80
85
90
10
15
18
19
20
30
40
50
60
65
80
85
90
Insertion in a B+ Tree
Now insert 25
80
20
60
100
120
140
10
15
18
19
20
30
40
50
60
65
80
85
90
10
15
18
19
20
30
40
50
60
65
80
85
90
Insertion in a B+ Tree
After insertion
80
20
60
100
12 0
140
10
1 5
18
19
20
2 5
30
4 0
5 0
60
6 5
80
8 5
90
10
15
18
19
20
25
30
40
50
60
65
80
85
90
Insertion in a B+ Tree
But now have to split !
80
20
60
100
12 0
140
10
1 5
18
19
20
2 5
30
4 0
5 0
60
6 5
80
8 5
90
10
15
18
19
20
25
30
40
50
60
65
80
85
90
Insertion in a B+ Tree
After the split
80
20
30
60
100
12 0
140
10
1 5
18
19
20
2 5
30
4 0
5 0
60
6 5
80
8 5
90
10
15
18
19
20
25
30
40
50
60
65
80
85
90
Insertion in a B+ Tree
Another B+ Tree
80
20
30
60
70
100
12 0
140
10
1 5
18
19
20
2 5
30
4 0
5 0
60
6 5
80
8 5
90
10
15
18
19
20
25
30
40
50
60
65
80
85
90
Insertion in a B+ Tree
Now Insert 12
80
20
30
60
70
100
12 0
140
10
1 5
18
19
20
2 5
30
4 0
5 0
60
6 5
80
8 5
90
10
15
18
19
20
25
30
40
50
60
65
80
85
90
Insertion in a B+ Tree
Need to split leaf
80
20
30
60
70
100
12 0
140
10
1 2
15
1 8
1 9
20
2 5
30
4 0
5 0
10
12
15
18
19
20
25
30
40
50
Insertion in a B+ Tree
Need to split branch
80
15
2 0
30
6 0
7 0
100
12 0
140
10
1 2
15
1 8
1 9
20
2 5
30
4 0
5 0
10
12
15
18
19
20
25
30
40
50
Insertion in a B+ Tree
After split
30 80
15
20
60
70
100
12 0
140
10
1 2
15
1 8
1 9
20
2 5
30
4 0
5 0
10
12
15
18
19
20
25
30
40
50
If merge occurred, must delete entry (pointing to X or sibling) from parent of X. Merge could propagate to root, decreasing height.
80
20
30
60
100
12 0
140
10
1 5
18
19
20
2 5
30
4 0
5 0
60
6 5
80
8 5
90
10
15
18
19
20
25
30
40
50
60
65
80
85
90
100
12 0
140
10
1 5
18
19
20
2 5
40
5 0
60
6 5
80
8 5
90
10
15
18
19
20
25
40
50
60
65
80
85
90
20
30
60
100
12 0
140
10
1 5
18
19
20
2 5
40
5 0
60
6 5
80
8 5
90
10
15
18
19
20
25
40
50
60
65
80
85
90
80
100
12 0
140
10
1 5
18
19
20
40
5 0
60
6 5
80
8 5
90
10
15
18
19
20
40
50
60
65
80
85
90
19
30
60
100
12 0
140
10
1 5
18
19
2 0
40
5 0
60
6 5
80
8 5
90
10
15
18
19
20
40
50
60
65
80
85
90
80
100
12 0
140
10
1 5
18
19
2 0
50
60
6 5
80
8 5
90
10
15
18
19
20
50
60
65
80
85
90
19
60
100
12 0
140
10
1 5
18
19
2 0
5 0
60
6 5
80
8 5
90
10
15
18
19
20
50
60
65
80
85
90