Introduction
A static multilevel index from Indexing must be rebuilt as the file grows. B-trees and B+ trees are multilevel indexes that stay balanced under inserts and deletes: every leaf is at the same depth, and every node except the root is at least half full. One node is one disk block, so the number of levels (edge height plus 1) is the number of index block accesses for a search.
The standard calculations are the order of a node from the block, key and pointer sizes, the minimum and maximum number of keys or levels, and the tree after a sequence of insertions or deletions.
Prerequisites
- Indexing: Primary, Clustering, Secondary and Multilevel Indexes: fan-out, levels and block-access counts.
- Binary Search Trees: search order in a tree.
Core concepts
Order. The order of a node is its maximum number of child pointers; a node then holds at most keys. This is the convention of Elmasri and Navathe () and of Korth, Silberschatz and Sudarshan (). Other sources define order as the maximum number of keys, or use a minimum degree ; read the question's definition before computing.
B-tree of order .
- An internal node is with : tree pointers , keys in increasing order, and a data (record) pointer with every key.
- Every key appears exactly once in the tree, in an internal node or a leaf.
- Each non-root internal node has at least children; every non-root B-tree node, including leaves, has at least keys; the root has at least 2 children unless it is the only node. All leaves are at the same level.
B+ tree of order (internal) and (leaf).
- Internal nodes hold up to tree pointers and keys, with no data pointers; they only guide the search.
- Leaves hold up to pairs and one next-leaf pointer, so the leaves form a sorted linked list.
- Every key appears in a leaf; some keys are repeated in internal nodes as separators.
- Each internal node except the root has at least children; each leaf (when the root is not a leaf) has at least keys.

How it works
Search. From the root, follow the pointer between the two keys that bracket the search key (in a B+ tree, go right on equality, since keys equal to a separator are stored in its right subtree). A B-tree search may stop at an internal node; a B+ tree search always reaches a leaf. Cost: one block per level, plus one data block.
Range search in a B+ tree: find the first key, then walk the leaf chain. A B-tree has no leaf chain and needs an in-order traversal.
Insertion into a B+ tree (the convention used in the traces and in the checks):
- Insert the key in its leaf in sorted order. If the leaf now has keys, split it: the left leaf keeps the first keys, the right leaf gets the rest, and the first key of the right leaf is copied into the parent.
- If an internal node now has keys ( pointers), split it: the left node keeps the first pointers, the next key moves up (it is not kept below), and the right node gets the rest.
- A split of the root creates a new root with one key, so the tree grows at the top and all leaves stay at the same depth.
In a B-tree a full node splits around its median key, which moves up together with its data pointer; no key is copied. Some books put the extra key in the right half instead of the left; both give valid trees, so a problem that wants one exact tree must fix the rule.
Deletion removes the key from its leaf; if the leaf falls below the minimum it borrows from a sibling (redistribution) or merges with it, and the parent loses a separator, which can propagate up and shrink the root. One fixed rule is used, since books differ:
- A node that falls below its minimum looks at its left sibling under the same parent, or its right sibling if it is the leftmost child.
- If the two nodes fit in one node, merge them. Merging two leaves deletes the separator between them from the parent; merging two internal nodes pulls that separator down into the merged node.
- Otherwise borrow one entry. For leaves, move the nearest key across and set the parent's separator to the first key of the right leaf. For internal nodes, rotate: the parent's separator comes down into the short node, together with the nearest child pointer of the sibling, and the sibling's nearest key goes up to the parent.
- If the root is left with one child, that child becomes the root and the tree loses a level.
Mathematical explanation
Order from sizes. Block size , key , block (tree) pointer , record pointer :
Take the largest integer satisfying each. A B+ internal node has no record pointers, so its order is larger than the B-tree order for the same block: the larger internal fan-out can reduce the number of levels, but need not do so in every instance.
Height bounds for a B+ tree with keys and levels (the root is level 1, leaves are level , ):
The minimum uses a root with 2 children, minimum fan-out below it, and minimum leaves. So keys need at least the smallest with levels and at most the largest whose minimum does not exceed .
B-tree maximum. A B-tree of order and levels holds at most keys.
B-tree minimum. Let . The sparsest tree has a root with 1 key and 2 children, and every other internal node with children and keys, and every leaf with keys. Level then has nodes, so
Unlike the B+ minimum, every level contributes keys, because B-tree internal nodes hold keys of their own.
Worked examples
Example 1: orders. , , , .
- B-tree: .
- B+ internal: .
- B+ leaf: .
Example 2: levels for one million keys. With , and :
- Three levels hold at most , so at least 4 levels.
- Five levels need at least keys, so at most 4 levels.
- The tree has exactly 4 levels however full its nodes are. Packed full it has leaves, then , and nodes above them. A search reads 4 index blocks and 1 data block.
- A B-tree of order 40 with 3 levels holds at most keys; with 4 levels at most , so a B-tree of order 40 also needs at least 4 levels here.
- The B-tree height is not fixed, though. With the minimum is keys for 4 levels, for 5 and for 6. One million keys fit a sparse 5-level tree but not a 6-level one, so the B-tree has 4 or 5 levels depending on how full its nodes are.
- For small numbers the same formulas give, for the B+ tree of Example 3 (, ) with 3 levels, between and keys.
Example 3: inserting into a B+ tree of order 4 (, : at most 3 keys per node). Insert 20, 40, 10, 30, 15, 35, 7, 26, 18, 22, 5:
- 20, 40, 10 fill the root leaf . Inserting 30 splits it into and ; 30 is copied up into a new root.
- 15 and 35 fit. 7 splits into and ; 15 goes up: root .
- 26 fits in ; 18 splits it into and , and 20 goes up: root . 22 and 5 fit.
The tree is now root over leaves , , , .
Example 4: a split that reaches the root (Figure 2). Insert 42 into that tree. The leaf splits into and and copies 40 up. The root becomes , four keys, so it splits: stays left, 30 moves up into a new root, goes right. The tree now has 3 levels: root , internal nodes and , leaves , , , , .

Continuing with 13, 46 and 27 gives the tree of Figure 1: 13 splits and copies 10 up; 46 fits; 27 splits , copies 26 up, and the internal node splits with 20 moving up to the root.
Example 5: B-tree insertion. B-tree of order 5 (at most 4 keys per node), inserting 10, 20, ..., 90 in order:
- 10 to 40 fill the root . 50 makes 5 keys; the median 30 moves up: root over and .
- 60 and 70 fill ; 80 overflows it, and its median 60 moves up: root over , , .
- 90 fits: the final tree is root over , , , after 2 splits.
Unlike a B+ tree, 30 and 60 are stored only in the root; no leaf repeats them. Here the sorted input leaves every node except the rightmost at the minimum of keys.
Example 6: B+ deletion with the rule above. Start from the tree of Figure 1 (order 4: leaves need at least 2 keys, internal nodes at least 2 children). Delete 30, then 22, then 42.
- Delete 30. Leaf becomes , too small. It is the leftmost child of , so its sibling is ; together they have 4 keys, too many to merge, so it borrows 40: leaves and , and the parent's separator becomes 42. The root still holds 30, a key no longer in the tree. That is allowed: a separator only has to route searches correctly, and every key below 30 is still on its left.
- Delete 22. Leaf becomes ; it merges with its right sibling into , and the parent loses its only separator, leaving one child. That internal node merges with its left sibling , pulling the root separator 20 down: internal node with 4 children. Root: over and .
- Delete 42. Leaf becomes and merges with its left sibling into ; the parent is left with one child. Its left sibling has 4 children, too many to merge, so it borrows by rotation: 30 comes down from the root, the child moves across, and 20 goes up. Result: root ; internal nodes and ; leaves , , , , .
The tree keeps 3 levels throughout. The sibling rule matters: with the right sibling tried first, step 2 merges the short internal node with instead, pulling 30 down, and gives root over and , a different valid tree. (After step 3 the two rules happen to meet again.) A question that wants one exact tree must state the rule.
Important properties and observations
- One node is one block, so levels equal index block accesses; edge height is levels minus 1.
- B+ trees have larger fan-out than B-trees for the same block, because internal nodes carry no record pointers.
- Leaf split copies the separator up; internal split moves it up.
- All leaves are at one level; the tree grows and shrinks only at the root.
- Nodes are at least half full (except the root), which bounds the height by about .
- Range queries use the B+ leaf chain.
Common misconceptions.
- "Order means maximum keys." Under the pointer convention of Korth and Elmasri, order is maximum pointers; check the question.
- "A B+ tree stores data pointers in internal nodes." Only leaves have record pointers.
- "Every insert grows the height." Only a split that reaches the root does.
GATE examination perspective
- Order calculations. Apply this to B-tree, B+ internal and B+ leaf nodes.
- Minimum and maximum keys or nodes. Apply this to a given height, and the height range for keys.
- Insertion sequences. The final root, number of splits, or number of nodes.
- B-tree versus B+ tree. Where keys and data pointers live, and the leaf chain.
- Block accesses. Apply this to a search: levels plus one data block.
Summary
Sources
- A. Silberschatz, H. F. Korth, S. Sudarshan, Database System Concepts, 7th ed., McGraw-Hill, 2019 (2020 copyright), 14.3 B+-Tree Index Files, 14.4 B+-Tree Extensions.
- R. Elmasri, S. B. Navathe, Fundamentals of Database Systems, 7th ed., Pearson, 17.3 Dynamic Multilevel Indexes Using B-Trees and B+-Trees.