Skip to content
Official PYQ · 2025

GATE CS 2025 Set 2 Q47 — File Organization and Indexing (B and B+ Trees)

Explain with AI
In a B+\mathrm{B}^{+}- tree where each node can hold at most four key values, a root to leaf path consists of the following nodes:
A=(49,77,83,−),B=(7,19,33,44),C=(20∗,22∗,25∗,26∗)\mathrm{A}=(49,77,83,-), \mathrm{B}=(7,19,33,44), \mathrm{C}=\left(20^{*}, 22^{*}, 25^{*}, 26^{*}\right)

The ∗*-marked keys signify that these are data entries in a leaf.

Assume that a pointer between keys k1k_{1} and k2k_{2} points to a subtree containing keys in [k1,k2)\left[k_{1}, k_{2}\right), and that when a leaf is created, the smallest key in it is copied up into its parent.

A record with key value 2323 is inserted into the B+\mathrm{B}^{+}- tree.

The smallest key value in the parent of the leaf that contains 25∗25^{*} is __________. (Answer in integer)
View worked solution

Answer: 33:33

To insert the key 2323, we first traverse the B+\text{B}^+-tree along the given path:

  • From root A=(49,77,83,−)\mathrm{A} = (49, 77, 83, -), since 23<4923 < 49, we follow the first pointer to node B\mathrm{B}.
  • From B=(7,19,33,44)\mathrm{B} = (7, 19, 33, 44), since 19≤23<3319 \le 23 < 33, we follow the pointer between 1919 and 3333 to leaf node C=(20∗,22∗,25∗,26∗)\mathrm{C} = (20^*, 22^*, 25^*, 26^*).

Since leaf C\mathrm{C} is full (maximum capacity of 4 keys), inserting 2323 causes a split of the keys {20,22,23,25,26}\{20, 22, 23, 25, 26\}. Depending on the split policy, we have two standard cases:

Case 1: Left-biased split (2 keys left, 3 keys right)

  • Left leaf: C1=(20∗,22∗)\mathrm{C}_1 = (20^*, 22^*)
  • Right leaf: C2=(23∗,25∗,26∗)\mathrm{C}_2 = (23^*, 25^*, 26^*)
  • The smallest key in the right leaf, 2323, is copied up to parent B\mathrm{B}.

Case 2: Right-biased split (3 keys left, 2 keys right)

  • Left leaf: C1=(20∗,22∗,23∗)\mathrm{C}_1 = (20^*, 22^*, 23^*)
  • Right leaf: C2=(25∗,26∗)\mathrm{C}_2 = (25^*, 26^*)
  • The smallest key in the right leaf, 2525, is copied up to parent B\mathrm{B}.

In both cases, the leaf containing 25∗25^* is C2\mathrm{C}_2, and the key copied up to the parent B\mathrm{B} is Kup∈{23,25}K_{\text{up}} \in \{23, 25\}.

Now, parent B=(7,19,33,44)\mathrm{B} = (7, 19, 33, 44) is also full. Inserting KupK_{\text{up}} into B\mathrm{B} results in the key set {7,19,Kup,33,44}\{7, 19, K_{\text{up}}, 33, 44\}, causing B\mathrm{B} to split:

  • The middle key KupK_{\text{up}} is pushed up to root A\mathrm{A}.
  • B\mathrm{B} splits into left node B1=(7,19)\mathrm{B}_1 = (7, 19) and right node B2=(33,44)\mathrm{B}_2 = (33, 44).

The right leaf C2\mathrm{C}_2 (containing 25∗25^*) is pointed to by the leftmost child pointer of the newly created right internal node B2=(33,44)\mathrm{B}_2 = (33, 44). Thus, the parent of the leaf containing 25∗25^* is B2\mathrm{B}_2.

The smallest key value in B2\mathrm{B}_2 is 33.

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