0% found this document useful (0 votes)
9 views28 pages

B+ Trees - Upd

Uploaded by

adithya.pr2022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views28 pages

B+ Trees - Upd

Uploaded by

adithya.pr2022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Example of B+ tree

1
B+ Tree Example
• A balanced tree
• Each node can have at most m key fields and m+1 pointer
fields
• Half-­‐full must be satisfied (except root node):
• m is even and m=2d
– Leaf node half full: at least d entries
– Non-­‐leaf node half full: at least d entries
• m is odd and m = 2d+1
– Leaf node half full: at least d+1 entries
– Non-­‐leaf node half full: at least d entries (i.e.,
d+1 pointers)

2
Show the tree after insertions
• Suppose each B+ tree node can hold up to 4
pointers and 3 keys.
• m=3 (odd), d=1
• Half-­‐full (for odd m value)
– Leaf node should have at least 2 i.e.(d+1) keys.
– Non-­‐leaf nodes, at least 2 i.e.(d+1) pointers or (1
entry)
• Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10

3
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
• Insert 1

4
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
1

• Insert 3, 5

5
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
1

• Insert 3, 5
1 3 5

6
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
1 3 5

• Insert 7

7
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
1 3 5

• Insert 7

1 3 5 7

8
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
5

1 3 5 7

• Insert 9

9
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
5

1 3 5 7

• Insert 9

1 3 5 7 9

10
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
5

1 3 5 7 9

• Insert 2

11
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
5

1 3 5 7 9

• Insert 2
5

1 2 3 5 7 9

12
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
5

1 2 3 5 7 9

• Insert 4

13
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
5

1 2 3 5 7 9

• Insert 4
3 5

1 2 3 4 5 7 9

14
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
3 5

1 2 3 4 5 7 9

• Insert 6

15
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
3 5

1 2 3 4 5 7 9

• Insert 6

3 5 7

1 2 3 4 5 6 7 9

16
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
3 5 7

1 2 3 4 5 6 7 9

• Insert 8

17
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
3 5 7

1 2 3 4 5 6 7 9

• Insert 8
3 5 7

1 2 3 4 5 6 7 8 9

18
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
3 5 7

1 2 3 4 5 6 7 8 9

• Insert 10

19
Insert 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
3 5 7

1 2 3 4 5 6 7 8 9

• Insert 10
7

3 5 9

7 8 9 10

1 2 3 4 5 6
20
• Deletion

21
Show the tree after deletions
9

3 5 7 11

9 10 11 12

1 2 3 4 5 6 7 8

• Remove 9, 7, 8

22
9

3 5 7 11

9 10 11 12

1 2 3 4 5 6 7 8

• After removing 9

23
9

3 5 7 11

9 10 11 12

1 2 3 4 5 6 7 8

• After removing 9
7

3 5 9

7 8 10 11 12

1 2 3 4 5 6
24
Remove 9, 7, 8
7

3 5 9

7 8 10 11 12

1 2 3 4 5 6

• After removing 7

25
Remove 9, 7, 8
7

3 5 9

7 8 10 11 12

1 2 3 4 5 6

• After removing 7
7

3 5 11

8 10 11 12

1 2 3 4 5 6
26
Remove 9, 7, 8
7

3 5 11

8 10 11 12

1 2 3 4 5 6

• After removing 8

27
Remove 9, 7, 8
7

3 5 11

8 10 11 12

1 2 3 4 5 6

• After removing 8
3 5 7

1 2 3 4 5 6 10 11 12

28

You might also like