GATE / CS ARCHIVE

GATE CSE 2003 / QUESTION 65

Inserting a key in a 2–3–4 tree

Data Structures · B-Trees & Multiway Search Trees · Full GATE CSE 2003 paper

GATE 2003, Q65 2 marks · MCQ
Report issue

B-Trees & Multiway Search Trees

Question 65, GATE 2003: A 2–3–4 tree (B-tree of minimum degree 2) stores letters in alphabetical order. Its root is [L,P,U], with leaf children [B,H,I], [N], [Q,T], [V,X,Z] from left to right. GateForum asks for the result of inserting G; that request is omitted in GFG. Candidate trees (children listed left to right) are:
A. Root [P]; internal children [G,L] and [U]. Their leaf children are [B],[H,I],[N] and [Q,T],[V,X,Z].
B. Root [P]; internal children [H,L] and [U]. Their leaf children are [B,G],[I],[N] and [Q,T],[V,X,Z].
C. Root [I,P,U], with leaves [B,G,H],[L,N],[Q,T],[V,X,Z].
D. None of the above.
Use standard split-before-descent insertion to select the conventional result; the statement does not explicitly specify its insertion policy.
Tap to enlarge
Your answer
Answer & solution

Answer: B under standard split-before-descent insertion (no official key was published)

1. A minimum-degree-2 node holds at most three keys. The initial root is full, so split it before descending: promote P to a new root; its children hold [L] and [U]. The old four leaves are divided two per child.
2. G<P and G<L, so descend toward [B,H,I]. This child is full too. Promote its median H into [L], giving [H,L], and replace the leaf by [B] and [I].
3. G<H, so insert it into [B] to obtain [B,G]. The other leaves stay [I],[N],[Q,T],[V,X,Z]. These are exactly the links in B.
4. This is algorithm-dependent: A can arise under a bottom-up split choice, and C under redistribution. Neither the invariants alone nor the incomplete the wording uniquely force B.

Under standard top-down B-tree insertion, first split the full root [L,P,U], promoting P and giving children [L] and [U]. Descending left, split its full child [B,H,I], promoting H into [L] to obtain [H,L] and leaves [B],[I],[N]. Insert G into [B], giving [B,G]. The result is option B, with root [P], left child [H,L] and right child [U]. A different valid insertion policy can produce another valid B-tree: A follows suitable bottom-up split choices, and C uses redistribution to a sibling. Consequently B is the conventional algorithmic answer, not a uniquely forced tree from the B-tree invariants alone.

Original paper, page 9