A B-tree grows in an unusual way: new keys always go into leaves, and when a node overflows it splits and pushes its middle key up. When the root splits, a new root is created, so the tree grows at the top, and all leaves stay on the same level.
Insertion
To insert key k:
Search for k to find the leaf where it belongs; insert it there in sorted position.
If the leaf now has m keys (one too many), split it: the middle key moves up into the parent, the keys to its left form one node and the keys to its right another.
If the parent now overflows, split it too, and so on upwards. If the root splits, the middle key becomes a new root with two children: the height grows by 1.
(Cormen’s version splits every full node on the way down before inserting, so a single downward pass suffices; the resulting trees satisfy the same rules.)
Deletion (outline)
Deleting a key from a leaf may leave it with fewer than ⌈m/2⌉−1 keys (underflow). It is repaired by:
borrowing: if a neighbouring sibling has more than the minimum, move a key from the parent down into the node and a key from the sibling up into the parent (a rotation);
merging: otherwise merge the node, its sibling and the separating key from the parent into one node; the parent loses a key and may underflow in turn.
A key in an internal node is first replaced by its inorder predecessor or successor (which is in a leaf), and that key is deleted from the leaf. If the root loses its last key, its single child becomes the new root and the height shrinks by 1.
Applications
Database indexes: almost every relational database (MySQL InnoDB, PostgreSQL, Oracle, SQL Server) stores indexes as B-trees or B+ trees, giving O(logn) look-up instead of O(n) for an unindexed scan.
File systems: NTFS, ext4 (directory indexes), HFS+/APFS and Btrfs use B-tree variants to find files and blocks.
B+ trees (a variant) keep all records in the leaves and link the leaves in a list, so range queries (“all orders from March”) are fast.
Key takeaways
Insert into a leaf; on overflow (m keys) split and move the middle key up.
Splits can travel up to the root; a root split adds a new root (height + 1).
Deletion repairs underflow by borrowing from a sibling or merging with it.
Used in database indexes and file systems; B+ trees add linked leaves for range queries.
Practice questions
Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 6 · short answer
Insert 10, 20, 30, 40, 50, 60, 70 into an empty B-tree of order 3 (at most 2 keys per node), drawing the tree after each split.
Show worked answer
[10 20]; insert 30 → [10 20 30] overflows: split, 20 moves up: root [20], leaves [10] [30]. Insert 40 → [30 40]. Insert 50 → [30 40 50] overflows: 40 moves up: root [20 40], leaves [10] [30] [50]. Insert 60 → [50 60]. Insert 70 → [50 60 70] overflows: 60 moves up to root [20 40 60], which overflows: 40 moves up to a new root. Final: root [40]; level 2: [20] [60]; leaves [10] [30] [50] [70]. All leaves are on level 3.
MCA Online notes are made for reading on screen. Open https://mcastudy.online/mcs-208/advanced-trees/b-tree-insertion-deletion-and-applications/ to read this page.