Data Structures · UGC NET: Advanced Data Structures
B-Trees, B+ Trees and B Star Trees
Overview
B-tree, B+ tree and B tree* are balanced multiway search trees designed mainly for disk-based storage, where one node is usually one disk block.
A B-tree keeps all leaves at the same level and stores keys plus data pointers in any node. A B+ tree stores all actual records/data pointers only in linked leaf nodes and uses internal nodes as an index.
A B* tree is a B-tree variant that delays splitting by redistributing keys with siblings, giving at least two-thirds occupancy for non-root nodes.
You need basic binary search tree search, insertion and deletion ideas, plus disk block and pointer accounting. These structures are standard in DBMS file organisation, indexing and file systems.
Key concepts
- Order used here means the maximum number of children a node may have. A node with keys has exactly children. Therefore maximum keys per node is .
- For a B-tree of order , every non-root node must have at least children, hence at least keys. The root may have fewer.
- In CLRS minimum degree notation, a node has at most keys and at most children. Every non-root node has at least keys and at least children. Relation with the order convention: maximum children .
- All leaves of a B-tree are at the same depth. Insertion grows the tree upward by splitting the root; it never pushes leaves downward.
- A B+ tree keeps actual data pointers/records only at the leaf level. Internal nodes contain only search-key copies and child pointers. Leaves are linked left-to-right for fast range queries.
- A B tree* is a B-tree with higher minimum occupancy: non-root nodes are at least two-thirds full. On overflow, keys are first redistributed to a sibling; if both relevant nodes are full, two nodes split into three.
- A split promotes a median key to the parent. In CLRS, a full node has keys; the median key moves up, left and right parts get keys each.
- Deletion first removes from a leaf if possible. If a node underflows, borrow from a sibling; otherwise merge with a sibling and a separator key from the parent. The underflow may propagate upward.
- A node stores keys and child pointers. A non-leaf B-tree node with children has keys and pointers. A B+ tree internal node with keys has pointers.
How it works
- Search in a B-tree. Start at the root. Compare the target key with the sorted keys in the node. If found, report success. If not, follow the child pointer between the two keys where the target lies.
Repeat until a leaf is reached. - Insertion in a B-tree. If the root is full, split it first and create a new root. Then descend towards the correct leaf. Before entering a full child, split that child and insert its median key into the parent.
Finally insert the new key into the non-full leaf. - Split operation. Let a full node contain keys in CLRS notation. The median key moves to the parent. The left part keeps keys, the right part keeps keys, and the child pointers are divided accordingly.
In an order- tree, when a full node receives one extra key, the middle of the combined keys moves upward. - Why B-tree height increases only at the root. A split inside the tree only moves a key to the parent. If the root splits, a new root is created above it, so all leaves remain at the same depth.
This preserves the balanced-height property. - Deletion cases. If the key is in a leaf and removal still leaves enough keys, delete it. If removal causes underflow, borrow a key from a left or right sibling.
If borrowing is impossible, merge the node with a sibling and the separator key from the parent. If the key is in an internal node, replace it with its predecessor or successor from a leaf, then delete that leaf key.
If both children adjacent to an internal key have the minimum number of keys, merge them with the key, remove the key from the parent, and propagate underflow if needed. - B+ tree operations. Search always goes down to a leaf. Insertion inserts into the correct leaf; if the leaf splits, the first key of the new right leaf is copied up to the parent. Internal splits promote a median key.
For a range query, find the first qualifying key in a leaf, then follow leaf next-pointers sequentially. - B tree insertion.* When a node overflows, try to redistribute some keys to a sibling. Update the separator key in the parent.
If both relevant nodes are full, split two full nodes into three nodes, each about two-thirds full, and move the required separator keys upward. This reduces the number of splits and increases storage utilisation.
Drawing the diagram…
Formulas
-
Use order = maximum number of children; maximum keys = .
-
Minimum children of a non-root internal node:
-
Minimum keys of a non-root node:
-
CLRS minimum degree : maximum keys , minimum non-root keys , maximum children , minimum non-root children .
-
B* tree non-root occupancy: at least two-thirds full. Under the maximum-children convention, minimum children is often written as
and minimum keys as
Some books state “two-thirds of capacity”; follow the convention stated in the question. -
Maximum height with root height . Let . Minimum number of keys in a B-tree of height is
Hence -
Non-leaf B-tree node memory: with key size , pointer size , and maximum children ,
-
B+ tree internal node with keys and child pointers, block size :
-
B+ tree leaf node with keys, record pointer size , and one next-leaf pointer :
If the next-leaf pointer is not counted, use . -
Average split bound. Let be the number of nodes, total splits while building from empty, and . Since each non-root node has at least keys,
Worked examples
Example 1: B-tree node memory. A B-tree uses maximum children . Each key is bytes and each child pointer is bytes. A non-leaf node has keys and pointers. Memory bytes. Using the formula: .
If one disk block is bytes, solve . Then , so . Maximum integer , giving bytes, which fits.
Example 2: B+ tree fanout. A B+ tree uses disk blocks of bytes, key size bytes, child pointer size bytes. For an internal node, maximum keys satisfy . Thus , , , so , with child pointers.
Check: . If each leaf also has one next-leaf pointer of bytes and record pointer bytes, leaf maximum keys satisfy , so , again .
Example 3: Insertion into an order-3 B-tree. This is a 2-3 tree: maximum keys per node. Insert : root . Insert : root . Insert : node overflows as ; median moves up. Root , children and .
Insert : goes to right child . Insert : right child overflows as ; median moves up. Root becomes , children , , . Insert : goes to rightmost child and becomes .
Final root , children , , .
Example 4: Maximum height. For order , . Minimum keys for height is . For , minimum keys . For , minimum keys . If , height is possible because , but height is impossible because .
Hence maximum height is under root height .
Example 5: Statement type. Statement I: In a B+ tree, sequential range queries are efficient because all leaves are linked. True. Statement II: A B* tree tries redistribution with a sibling before splitting a full node. True.
Statement III: In a standard B-tree, data pointers occur only at leaf nodes. False; a B-tree may store data pointers with keys in internal nodes also. Therefore I and II are true, III is false.
Comparison
| Feature | B-tree | B+ tree | B* tree |
|---|---|---|---|
| Data pointers | In all nodes | Only in leaves | In all nodes, like B-tree |
| Internal node keys | Actual keys | Routing key copies | Actual keys |
| Leaves linked | Usually no | Yes, left-to-right | Usually no |
| Search ends | May end at internal node | Always at a leaf | May end at internal node |
| Range query | Inorder/backtracking | Efficient by leaf links | Inorder/backtracking |
| Minimum occupancy | About half full | About half full | At least two-thirds full |
| Overflow handling | Split full node | Split leaf/internal node | Redistribute to sibling first; then split |
| Main advantage | General balanced index | Fast range and sequential access | High storage utilisation, fewer splits |
| Convention | Maximum keys | Minimum non-root keys | Maximum children |
|---|---|---|---|
| Order | |||
| CLRS degree |
Revision summary
- Order here means maximum children, not maximum keys.
- Maximum keys in order is ; a node with keys has children.
- CLRS : maximum keys , minimum non-root keys .
- Split promotes the median key; in CLRS the median is the -th key.
- B-tree grows upward by splitting the root, keeping all leaves at one level.
- Deletion underflow: borrow first; if impossible, merge with separator.
- B+ tree: data only at leaves; leaves linked; internal keys are copies.
- B* tree: non-root nodes at least two-thirds full; redistribute before split.
- Non-leaf B-tree memory: , not just keys.
- B+ internal node with keys has child pointers.
- Height bound uses : minimum keys.
- Average split bound is .
Previous-year exam insights
- Direct formula questions ask maximum/minimum keys, minimum children, node memory, or fanout from block size.
Check whether the question uses order or CLRS minimum degree . - Numeric questions often require two steps: first find fanout from block size, then use that fanout in height or memory calculation.
- Insertion questions test the exact median that moves upward.
In a 2-3 tree, it is the middle of three keys; in CLRS, it is the -th key of the full node. - Deletion questions trap students on borrow versus merge.
If both adjacent children have minimum keys, merge with the separator; do not try to borrow. - Statement and match-list questions mix B-tree, B+ tree and B* tree properties.
B+ leaves are linked and data is only at leaves; B* has two-thirds occupancy and redistribution. - A common wrong option counts keys for order , or forgets the extra child pointer in a node with keys.
- The average-split formula follows from counting minimum keys per non-root node and the fact that each split adds one node.
- For B+ tree block-size questions, count internal child pointers as , and count leaf record pointers plus any next-leaf pointer if the question mentions it.
Practice at PARIKSHA
You are ready for the PARIKSHA tests of this sub-topic when you can:
- State maximum keys, minimum keys and minimum children for a B-tree of order and for CLRS minimum degree .
- Convert between order and degree and avoid mixing their formulas.
- Compute the memory of a non-leaf B-tree node from key size, pointer size and maximum children.
- Compute maximum keys in a B+ tree internal node and leaf node from block size and pointer sizes.
- Trace insertion into a small B-tree and identify the median key moved upward at each split.
- Apply deletion rules for leaf underflow, internal-node deletion and merging with a separator.
- Derive and use the maximum height bound with root height .
- Explain why B-trees grow upward and why this preserves equal leaf depth.
- Distinguish B-tree, B+ tree and B* tree on data placement, leaf links, occupancy and split strategy.
- Answer statement-type and match-list questions on B+ leaf links, B* two-thirds occupancy and B-tree data pointers.
Attempt the sub-topic test first, then the subject test.