B-Trees Overview
B-trees store multiple keys per node and keep leaves at the same depth. They are designed for block-oriented storage (hard drive, SSD pages).
Compared to AVL trees: fewer rotations along the path, wider nodes, typically found in databases and file systems.
high branching, balanced height.
| Structure | Height idea | Typical storage |
|---|---|---|
| BST | can degenerate to a chain | RAM, nodes |
| AVL | balance | |
| B-tree | high fan-out, leaves level | blocks / pages |
| ## Where used |
Database and file system indexes (InnoDB, NTFS/HFS ideas), because high branching factors align with the block sizes of SSDs/HDDs. Less random I/O per search than with binary nodes.
Depth
A B-tree stores multiple sorted keys per node and accordingly has multiple children. All leaves are at the same level. The high branching reduces the number of nodes visited on a search path.
This structure is suitable for block-oriented storage. A node is sized to read many keys with a single page access. The relevant cost metric is therefore often the number of memory accesses rather than individual comparisons.
When inserting, a full node is split and a separating key is promoted to the parent node. Deletion may require borrowing or merging to maintain minimum occupancy.
Difficulty levels
- Assign key ranges to the children of a node.
- Track a node split and the promotion.
- Justify high branching with external storage blocks.
Pitfalls
A B-tree is not a binary tree. The allowable number of keys depends on the ordering definition used, which is often noted differently in textbooks.
Tasks
Card Info
- Topic: Algorithms and Data Structures
- Difficulty: Beginner
- Completed: 0 users