GATE / CS ARCHIVE

GATE CSE 1997 / QUESTION 19(a)

Count B+-tree internal keys

Database Management Systems · Indexing, Storage & Query Processing · Full GATE CSE 1997 paper

GATE 1997, Q19(a) 2 marks · Descriptive
Report issue

Indexing, Storage & Query Processing

Question 19(a), GATE 1997: In this question a B+-tree of order d has d to 2d key entries in each nonroot internal node, and an internal node with M keys has M+1 children. An internal root has 1 to 2d keys. All leaves are at equal edge-distance h from the root. Use this stated convention, not the alternative convention that “order” means maximum fan-out. With ℓ≥2 leaves, how many key entries are stored across all internal nodes?
Question 19(a), GATE 1997: In this question a B+-tree of order d has d to 2d key entries in each nonroot internal node, and an internal node with M keys has M+1 children. An internal root has 1 to 2d keys. All leaves are at equal edge-distance h from the root. Use this stated convention, not the alternative convention that “order” means maximum fan-out. With ℓ≥2 leaves, how many key entries are stored across all internal nodes?
Question 19(a), GATE 1997: In this question a B+-tree of order d has d to 2d key entries in each nonroot internal node, and an internal node with M keys has M+1 children. An internal root has 1 to 2d keys. All leaves are at equal edge-distance h from the root. Use this stated convention, not the alternative convention that “order” means maximum fan-out. With ℓ≥2 leaves, how many key entries are stored across all internal nodes?
Tap to enlarge
Answer & solution

Answer: ℓ−1 internal key entries. (no official key was published)

Let I be the number of internal nodes and let kv be the number of key entries in internal node v. That node has kv+1 children, so summing all internal-node child counts counts every tree edge exactly once:

Σ_internal v (kv+1) = number of edges.

The whole tree has I+ℓ nodes and is connected and acyclic, so it has I+ℓ−1 edges. Therefore

Σ kv + I = I+ℓ−1,
and hence Σ kv = ℓ−1.

This argument includes the root, whose minimum occupancy differs from other internal nodes. It does not depend on the height, branching distribution, or order d, only on the fact that every internal node has one more child than key entries.

For a root with three leaf children, there are two root keys and ℓ−1=2. If an internal node with five leaf children is inserted one level lower, its four keys and the necessary separator keys above it still obey the same identity. The result counts stored separator entries in internal nodes; it is not the number of data records in the leaves, nor a claim about the number of distinct values across the entire B+-tree. Leaf keys can have different occupancy conventions without affecting this edge-count identity.

Original paper, page 9