Consider the following tree (i.e., B-tree with a minimum degree of two) in which each data item is a letter. The usual alphabetical ordering of letters is used in constructing the tree.

What is the result of inserting in the above tree?
View worked solution
Answer: B
In a 2-3-4 tree (a B-tree of order 4), insertion is performed using a top-down approach. As we search for the insertion location from the root to the leaf, any 4-node (a node containing 3 keys) encountered along the path is split immediately. This proactive splitting ensures that we never have to propagate splits back up the tree.
Let's trace the insertion of key step-by-step:
- Identify the path: We start at the root . Since , we must descend to its left child, which is the 4-node .
- Split the 4-node :
- The middle key is promoted to the root, changing the root to .
- The remaining keys split into two 2-nodes: and .
- The children are distributed: gets and , while gets and .
- Descend and Insert:
- From the new root , since , we move to the left child .
- Since , we descend to the right child of , which is the leaf node .
- Since is not a 4-node, we insert directly into it, resulting in .
The right child of the root, , is not visited during this insertion, so it remains unsplit. This resulting structure corresponds exactly to Option B.
Free practice · Your answers on this page are not saved.
