B-Tree Simulator
A B-Tree is a balanced multiway search tree designed to keep its height small. Each node stores several sorted keys and may have several children. B-Trees are widely used in databases and file systems because a single node can correspond to one storage page.
SearchO(log n)
InsertO(log n)
DeleteO(log n)
All leavesSame depth
Tree operations
Example B-Tree loaded. Choose an operation.
Keys0
Nodes0
Height0
Structural changes0
Search path
—
Sorted traversal
—
Node capacity for minimum degree t
non-root node: minimum keys = t - 1 maximum keys = 2t - 1 maximum children = 2t before descending into a full child: split the child move its median key to the parent
B-Tree concepts
Minimum degree
A non-root node contains between t − 1 and 2t − 1 keys.
Splitting
Insertion never descends into a full child. The child is split first and its median moves into the parent.
Borrowing and merging
Deletion repairs minimally filled children by borrowing from siblings or merging nodes before descending.
B-Tree versus B+ Tree
A B-Tree may store records in internal or leaf nodes; a B+ Tree keeps records in leaves and usually links those leaves.
B-Tree invariants
| Invariant | Meaning |
|---|---|
| Sorted keys | Keys inside every node remain in increasing order. |
| Child ranges | Each child contains only keys in the range defined by adjacent parent keys. |
| Occupancy | Except for the root, every node has at least t − 1 keys. |
| Balance | Every leaf appears at the same depth. |