B+ Tree: What Is A B+ Tree Searching Insertion Deletion
B+ Tree: What Is A B+ Tree Searching Insertion Deletion
What is a B+ Tree
Searching
Insertion
Deletion
What is a B+ Tree
Definition and benefits of a B+Tree
What is a B+ Tree
What is a B+ Tree
Question: Is this a valid B+ Tree?
C
What is a B+ Tree
Answer:
1.Both tree in slide 3 and slide 4 are valid; how
you store data in B+ Tree depend on your
algorithm when it is implemented.
2.As long as the number of data in each leaf are
balanced, it doesnt matter how many data
you stored in the leaves. For example: in the
previous question, the n can be 3 or 4, but
can not be 5 or more than 5.
What is a B+ Tree
1.
What is a B+ Tree
2.The searching time in a B+ tree is much
shorter than most of other kinds of trees. For
example: To search a data in one million keyvalues, a balanced binary requires about 20
block reads, in contrast only 4 block reads is
required in B+ Tree.
(The formula to calculate searching time can
be found in the book. Page 492-493)
Searching
Since no structure change in a B+ tree during
Searching
Result:
Insertion
Since insert a value into a B+ tree may cause
25 28 30
Dose not violates
the 50% rule
Insertion
Result:
Insertion
Example #2: insert 70 into below tree
Insertion
Process: split the tree
50
50
55
55
60
60
65
65
70
70
Violate the
50% rule,
split the
leaf
Insertion
Result: chose the middle key 60, and place it
Insertion
The insert algorithm for B+ Tree
Data
Page Full
Index Page
Full
Action
NO
NO
YES
NO
1.
2.
3.
4.
YES
YES
1.
2.
3.
4.
5.
6.
Insertion
Exercise: add a key value 95 to the below
tree.
75 80 85 90 95
Violate the
50% rule,
split the leaf.
75 80
85 90 95
25 50 60 75 85
Insertion
Result: again put the middle key 60 to the
Deletion
Same as insertion, the tree has to be rebuild if the
This is OK.
60
65
Deletion
Result:
Deletion
Example #2: delete 25 from below tree, but 25
appears in the index page.
But
28 30
This is
OK.
Deletion
Result: replace 28 in the index page.
Add 28
Deletion
Example #3: delete 60 from the below tree
65
50
55
65
Violet the
50% rule
Deletion
Result: delete 60 from the index page and
Deletion
Delete algorithm for B+ trees
Data Page Below Fill
Factor
Action
NO
NO
YES
NO
YES
YES
1.
2.
3.
Conclusion
For a B+ Tree:
It is easy to maintain its balance.
The searching time is short than most of
other types of trees.
Reference
http://babbage.clarku.edu/~achou/cs160/B+Tr
ees/B+Trees.htm
www.csee.umbc.edu/~pmundur/courses/CMS
C461-05/ch12.ppt