B+ Trees
March 25, 2024Properties
d
is the order- Each node except root must have
d <= x <= 2d
entries - Entries within each node is sorted
2d
entries will have2d + 1
pointers- Leaf nodes have same depth
- Inner nodes act as guide posts
- Leaf nodes contain records or pointer to records
Search
- Find entry
i
in node such thatk >= i
andk < i+1
- Get pointer such that k is in the range
- Go to node referenced by pointer
Insert
- Find node
L
by traversing. Add<key, record>
to the leaf node - If
L
overflows- Split into
L1
andL2
- Add
d
entries toL1
, addd+1
entries toL2
- If leaf node, COPY
L2
's first entry to parent - If not leaf, MOVE
L2
's first entry to parent (Make sure the nodes are sorted and in order) - Adjust pointers
- Split into
- If parent overflows, repeat
#2
for parent
Deletion
- Find leaf node
L
- Delete entry from leaf node. That's it for now. Keep it simple.
- No merging
Doubts
- Is the entire B tree loaded into memory?
- partially or completely??
- Especially if the leaf nodes hold the data pages
© 2023 Arjun Handli