Skip to content
Official PYQ · 2003

GATE CS 2003 Q65 — File Organization and Indexing (B and B+ Trees)

Explain with AI

Consider the following 2−3−42-3-4 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 GG in the above tree?

Choose one option
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 GG step-by-step:

  1. Identify the path: We start at the root [M][M]. Since G<MG < M, we must descend to its left child, which is the 4-node [D,H,L][D, H, L].
  2. Split the 4-node [D,H,L][D, H, L]:
    • The middle key HH is promoted to the root, changing the root to [H,M][H, M].
    • The remaining keys split into two 2-nodes: [D][D] and [L][L].
    • The children are distributed: [D][D] gets [B,C][B, C] and [E,F][E, F], while [L][L] gets [J,K][J, K] and [N,O][N, O].
  3. Descend and Insert:
    • From the new root [H,M][H, M], since G<HG < H, we move to the left child [D][D].
    • Since G>DG > D, we descend to the right child of [D][D], which is the leaf node [E,F][E, F].
    • Since [E,F][E, F] is not a 4-node, we insert GG directly into it, resulting in [E,F,G][E, F, G].

The right child of the root, [P,T,X][P, T, X], 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.

Published
Report a correction
Keep exploringMore File Organization and Indexing (B and B+ Trees) questions