BTree BPlusTree Theory Summary Final
BTree BPlusTree Theory Summary Final
Definition:
A B-Tree is a self-balancing tree data structure used for storing sorted data. It enables logarithmic time for insertion,
Operations in B-Tree:
- Search: Start from the root, use binary search in each node, and proceed to children if needed.
- Insertion: If the node is full, split it. Promote the middle key to the parent and continue inserting in the correct child.
- Deletion: Delete from the leaf. If a node falls below minimum keys, borrow from sibling or merge with sibling.
Definition:
A B+ Tree is an extension of the B-Tree that stores all data only in the leaf nodes, while internal nodes serve only as
routing indexes. It is designed for systems that read and write large blocks of data efficiently.
Key Properties:
2. Leaf nodes contain the actual data and are linked together using pointers.
Operations in B+ Tree:
- Search: Traverse from root to leaf. Always ends at a leaf node where actual data is found.
- Insertion: Insert into a leaf node. If it overflows, split the leaf. Propagate changes upward if necessary.
- Deletion: Remove from the leaf. If underflow occurs, borrow from or merge with neighboring nodes.
Use Cases: Databases like MySQL, large-scale indexing systems, file systems.
|-----------------------|-------------------------------|-------------------------------------|
| Internal Nodes | Contain both keys and data | Contain only keys |
| Leaf Node Linking | Not linked | Linked for fast range traversal |
| Search Path | May end in internal node | Always ends in leaf node |
| Use Cases | File systems, in-memory DBs | Database indexing, disk-based DBs |
Summary
- Use B+ Tree for high-performance indexing and fast range queries, especially on disk-based systems.