A B+ Tree is a self-balancing search tree and a variant of the B-Tree. Like a B-Tree, each internal node can hold multiple keys and have more than two children. The key difference is that in a B+ Tree all data records are stored only in the leaf nodes, while internal nodes act purely as routing guides. Leaf nodes are also connected in a Linked List, enabling efficient range queries without traversing the tree.
When inserting a new key, it is placed into the appropriate leaf node. If the leaf overflows, it splits — the smallest key of the right half is copied (not moved) up to the parent as a separator, so the key remains in the leaf. This copying behaviour is what distinguishes a B+ Tree from a B-Tree. Internal nodes split using the traditional median-push approach. The splitting process can propagate upward and may create a new root, always keeping all leaves at the same depth.
For simplicity, the order of this B+ Tree visualizer is fixed to 3.
(5 credits)
See what happens with your input
Get a short, step-by-step explanation of this visualization. Turn on AI Summary, then start a fresh run with your input.
A search operation in a B+ Tree always traverses from the root down to a leaf node. At each internal node, the algorithm compares the search key against the routing keys to determine which child subtree to visit. Even if an exact match is found inside an internal node, traversal continues downward into the child branch because the actual data record pointer is stored only in the leaf.
To execute a range query (e.g. finding all values between 20 and 50), the B+ Tree first performs a standard search to locate the leaf containing the lower bound. From there, it simply follows the sequential next pointer of the leaf nodes to scan records directly in sorted order until exceeding the upper bound, completely avoiding tree traversal overhead.
B+ Trees are the universal default storage engine index for production relational databases, including MySQL (InnoDB), PostgreSQL, SQLite, and Microsoft SQL Server, as well as modern file systems like NTFS and XFS. Because real-world database queries frequently involve range filters (between, >=, <=) and sorting (order by), the linked leaf structure provides dramatically higher query throughput than standard B-Trees or hash indexes.
Metric / Operation | Complexity | Description |
|---|---|---|
| Point Search | O(log n) | Uniform height ensures all searches reach the leaf level in exactly the same logarithmic number of steps. |
| Range Query | O(log n + k) | Locates the starting leaf in O(log n) time, then traverses k matching elements sequentially via the leaf linked list. |
| Insertion | O(log n) | Inserts into a leaf node; splitting copies the separator key up to internal routing nodes in O(log n) time. |
| Deletion | O(log n) | Removes the key from the leaf; rebalancing borrows from adjacent leaves or merges leaves and updates parent routing keys. |
| Space Complexity | O(n) | Stores all n records in leaves plus routing keys in internal nodes. High fanout keeps overhead low. |
B+ Tree leaf nodes are linked in a sorted linked list. A range query only needs one O(log n) traversal to find the start key, then a linear scan along the leaf chain to collect all records in range — no backtracking up the tree. In a B-Tree, data scattered across internal nodes forces repeated upward/downward traversals.
All three basic operations — search, insert, and delete — run in O(log n) with a base of m (tree height ~ logm n). A range query retrieving k records costs O(log n + k): one top-down traversal to the first leaf plus a linear scan of k leaf entries.
B+ Trees give databases two key advantages: 1) Higher fanout — internal nodes hold only keys (no data records), fitting more separators per disk page and reducing tree height. 2) Efficient range scans — the leaf linked list enables BETWEEN, ORDER BY, and full table scans without revisiting internal nodes, which is critical for OLAP and query optimizers.
to join the discussion
Hand-picked resources to deepen your understanding
© 2025 See Algorithms. Code licensed under MIT, content under CC BY-NC 4.0