Indexing and B+ Trees notes for GATE DA: 14 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.
Indexing and B Trees notes
Chapter Roadmap: Indexing and B+ Trees
Chapter Journey
1. B+ Tree Structure, Insertion and Fanout Calculation
Current Topic • High Importance • Foundation for all indexing and disk I/O questions
2. Index Selection for SQL Query Processing
Upcoming • Moderate Importance • Applies B+ tree mechanics to query execution plans
What you will master: Deriving node capacity limits from block sizes, executing step-by-step B+ tree insertions, and avoiding classic split traps.
Why B+ Trees? The Core Intuition
The Disk I/O Problem
Database systems minimize slow disk accesses by reading data in fixed-size blocks (or pages). A good index must minimize the number of blocks read to find a record.
Why Not Binary Search Trees?
A binary tree has a maximum of two children per node. For a million records, the height is around 20, meaning up to 20 disk reads. This is inefficient.
The B+ Tree Solution
High Fanout: Each node can hold hundreds of keys, drastically reducing the tree height (typically to 3 or 4 levels for millions of records).
Balanced: All leaf nodes are at the exact same depth, guaranteeing predictable, worst-case O(logpN) search time.
Data at Leaves Only: Internal nodes act purely as a "map" or routing guide. Only leaf nodes contain Data Record Pointers.
Linked Leaves: Leaf nodes are connected via sequential pointers, making range queries highly efficient without traversing back up the tree.
B+ Tree Structural Rules
Let p be the maximum number of tree pointers (fanout) in a non-leaf node, and pleaf be the maximum number of data entries in a leaf node.
Node Type
Pointer/Key Constraints
Data Pointers?
Root
Min 2 pointers, Max p pointers (if not a leaf).
Only if it is the sole node.
Internal
Min ⌈p/2⌉ pointers, Max p pointers.
Never. Contains only keys and block pointers.
Leaf
Min ⌈pleaf/2⌉ entries, Max pleaf entries.
Yes. Contains keys, data record pointers, and one next-leaf pointer.
Critical Property: Every key value that appears in an internal node also appears in the leaf level. Internal keys act as "separators" or "guideposts", not as the actual data location.
11 more cards in this chapter
Try a question
Answer it here to see how it works. Nothing is recorded until you sign in.
Question 1
Level 1: Warm-up
A B+ tree non-leaf node has a block size of B=104 bytes. The tree pointer size is Ptr=10 bytes, and the search key size is V=5 bytes. What is the maximum number of tree pointers p this node can hold?
Question 2
Level 1: Warm-up
A disk block is 1024 bytes. A B+ tree non-leaf node uses 10-byte tree pointers and 14-byte search keys. What is the maximum number of search keys that can be stored in a single non-leaf node?
Question 3
Level 1: Warm-up
Consider the following Assertion and Reason regarding B+ tree node capacity calculations:
Assertion (A): For a node of size 4 KB, with 10-byte tree pointers and 15-byte search keys, the maximum non-leaf fanout is 164.
Reason (R): The calculation for this fanout uses the inequality 25p≤4000, which yields p=160.
Question 4
Level 1: Warm-up
In a B+ tree where each leaf node can hold at most 5 entries, which of the following entry counts is impossible for a leaf node, assuming the tree contains more than one leaf node?
Question 5
Level 1: Warm-up
In a B+ tree diagram, an internal node contains a single separator key $40$, pointing to a left leaf $L_1$ and a right leaf $L_2$. Assuming standard B+ tree properties where all actual data pointers are at the leaves, which of the following pairs of leaf contents is IMPOSSIBLE?
Question 6
Level 1: Warm-up
Which of the following is IMPOSSIBLE for a non-leaf internal node in a B+ tree of order p=5 (assuming it is not the root)?
Question 7
Level 1: Warm-up
A database system uses a block size of $2048$ bytes for its B+ tree index. The search key size is $16$ bytes, the data record pointer size is $8$ bytes, and the next-leaf pointer size is $8$ bytes. What is the maximum number of entries $p_{leaf}$ that can be stored in a leaf node?
Question 8
Level 1: Warm-up
A B+ tree non-leaf node is built with a block size of $1024$ bytes. The tree pointer size is $8$ bytes and the search key size is $10$ bytes. What is the maximum number of tree pointers this non-leaf node can hold?
Question 9
Level 1: Warm-up
A B+ tree index is built with the following specifications:\\
\\
Block size: $2$ KB\\
Tree pointer size: $6$ bytes\\
Search key size: $10$ bytes\\
\\
What is the maximum number of tree pointers $p$ that can be stored in a non-leaf node?
Question 10
Level 1: Warm-up
In a B+ tree, if a non-leaf internal node has a maximum of p tree pointers, how many search keys does it contain?
Free preview ends here
Login to view the complete notes
Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.
Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.
Built around you, not around a syllabus PDF
Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.
Revision that hits your weak spots
We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.
Questions calibrated to the real exam
Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.
Notes written for recall, not for volume
Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.
One place for everything
Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.
Honest progress
No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.
Unlock the whole course
Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.
Indexing and B+ Trees notes for GATE DA: 14 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.
Chapter Roadmap: Indexing and B+ Trees
Chapter Journey
1. B+ Tree Structure, Insertion and Fanout Calculation
Current Topic • High Importance • Foundation for all indexing and disk I/O questions
2. Index Selection for SQL Query Processing
Upcoming • Moderate Importance • Applies B+ tree mechanics to query execution plans
What you will master: Deriving node capacity limits from block sizes, executing step-by-step B+ tree insertions, and avoiding classic split traps.
Why B+ Trees? The Core Intuition
The Disk I/O Problem
Database systems minimize slow disk accesses by reading data in fixed-size blocks (or pages). A good index must minimize the number of blocks read to find a record.
Why Not Binary Search Trees?
A binary tree has a maximum of two children per node. For a million records, the height is around 20, meaning up to 20 disk reads. This is inefficient.
The B+ Tree Solution
High Fanout: Each node can hold hundreds of keys, drastically reducing the tree height (typically to 3 or 4 levels for millions of records).
Balanced: All leaf nodes are at the exact same depth, guaranteeing predictable, worst-case O(logpN) search time.
Data at Leaves Only: Internal nodes act purely as a "map" or routing guide. Only leaf nodes contain Data Record Pointers.
Linked Leaves: Leaf nodes are connected via sequential pointers, making range queries highly efficient without traversing back up the tree.
B+ Tree Structural Rules
Let p be the maximum number of tree pointers (fanout) in a non-leaf node, and pleaf be the maximum number of data entries in a leaf node.
Node Type
Pointer/Key Constraints
Data Pointers?
Root
Min 2 pointers, Max p pointers (if not a leaf).
Only if it is the sole node.
Internal
Min ⌈p/2⌉ pointers, Max p pointers.
Never. Contains only keys and block pointers.
Leaf
Min ⌈pleaf/2⌉ entries, Max pleaf entries.
Yes. Contains keys, data record pointers, and one next-leaf pointer.
Critical Property: Every key value that appears in an internal node also appears in the leaf level. Internal keys act as "separators" or "guideposts", not as the actual data location.
Worked Example: Non-Leaf Fanout Calculation
Given:
Node Size (B) = 4096 bytes
Node Pointer Size (Ptr) = 10 bytes
Search Key Size (V) = 11 bytes
Data Record Pointer Size = 12 bytes (Not used for non-leaf calculation)
Objective: Find maximum node pointers (p) in a non-leaf node.
Indexing and B+ Trees: Solved Questions with Step-by-Step Explanations (10 Problems)
Question 1 · Database Management and WarehousingMCQ
A B+ tree non-leaf node has a block size of B=104 bytes. The tree pointer size is Ptr=10 bytes, and the search key size is V=5 bytes. What is the maximum number of tree pointers p this node can hold?
A.
7
B.
6
C.
8
D.
9
Correct Answer:
A
Step-by-Step Solution
Key idea: This is a direct formula application for calculating non-leaf node fanout.
Step 1: Recall the inequality for non-leaf nodes: p⋅Ptr+(p−1)⋅V≤B.
Step 2: Substitute the given values: 10p+5(p−1)≤104.
Step 3: Simplify the inequality: 10p+5p−5≤104⟹15p−5≤104.
Step 4: Solve for p: 15p≤109⟹p≤7.26.
Step 5: Since p must be an integer, the maximum value is ⌊7.26⌋=7.
Answer: 7
Question 2 · Database Management and WarehousingMCQ
A disk block is 1024 bytes. A B+ tree non-leaf node uses 10-byte tree pointers and 14-byte search keys. What is the maximum number of search keys that can be stored in a single non-leaf node?
A.
42
B.
43
C.
41
D.
44
Correct Answer:
A
Step-by-Step Solution
Key idea: This is an estimation question about B+ tree fanout calculation, recognizable by the need to solve the block size inequality for the maximum number of keys.
Step 1: Set up the inequality for a non-leaf node. Let p be the max pointers. 10p+14(p−1)≤1024.
Step 2: Simplify the inequality: 24p−14≤1024⟹24p≤1038.
Step 3: Solve for p: p≤1038/24=43.25. Since p must be an integer, max pointers p=43.
Step 4: The maximum number of search keys is p−1=43−1=42.
Answer: A
Question 3 · Database Management and WarehousingMCQ
Consider the following Assertion and Reason regarding B+ tree node capacity calculations:
Assertion (A): For a node of size 4 KB, with 10-byte tree pointers and 15-byte search keys, the maximum non-leaf fanout is 164.
Reason (R): The calculation for this fanout uses the inequality 25p≤4000, which yields p=160.
A.
Both A and R are true and R is the correct explanation of A
B.
A is true but R is false
C.
Both A and R are true but R is NOT the correct explanation of A
D.
A is false but R is true
Correct Answer:
B
Step-by-Step Solution
Key idea: This is an assertion-reason question testing the correct unit conversion and formula application for fanout.
Step 2: Apply the non-leaf formula: 10p+15(p−1)≤4096⟹25p−15≤4096⟹25p≤4111⟹p≤164.44.
Step 3: Maximum integer p=164. Assertion (A) is TRUE.
Step 4: Evaluate Reason (R). The reason claims the calculation uses 25p≤4000. This implies the student incorrectly converted 4 KB to 4000 bytes instead of 4096 bytes.
Step 5: Because the correct calculation uses 4096, the statement in (R) describing the calculation is FALSE.
Answer: A is true but R is false
Question 4 · Database Management and WarehousingMCQ
In a B+ tree where each leaf node can hold at most 5 entries, which of the following entry counts is impossible for a leaf node, assuming the tree contains more than one leaf node?
A.
2
B.
3
C.
4
D.
5
Correct Answer:
A
Step-by-Step Solution
Key idea: This is a boundary case question about minimum occupancy in B+ tree leaf nodes, recognizable by the phrase "impossible" and the constraint "more than one leaf."
Step 1: Recall the structural rule for leaf nodes in a B+ tree. Every leaf node (except when the tree has only one leaf) must be at least half full.
Step 2: Calculate the minimum number of entries. For a leaf with maximum capacity pleaf=5, the minimum is ⌈pleaf/2⌉=⌈5/2⌉=3.
Step 3: Any leaf node must have between 3 and 5 entries. Therefore, 2 entries is impossible.
Answer: A
Question 5 · Database Management and WarehousingMCQ
In a B+ tree diagram, an internal node contains a single separator key $40$, pointing to a left leaf $L_1$ and a right leaf $L_2$. Assuming standard B+ tree properties where all actual data pointers are at the leaves, which of the following pairs of leaf contents is IMPOSSIBLE?
A.
L1: [10, 20], L2: [40, 50]
B.
L1: [20, 30], L2: [40, 60]
C.
L1: [10, 30], L2: [50, 60]
D.
L1: [30], L2: [40, 50, 60]
Correct Answer:
C
Step-by-Step Solution
Key idea: This is a boundary case question about B+ tree separator keys, recognizable by the need to identify which leaf configuration violates the structural rule that internal keys must be duplicated in the leaves.
Step 1: Recall the critical property of B+ trees: every key value that appears in an internal node as a separator must also appear in the leaf level to act as a valid data entry.
Step 2: The internal node has separator key 40. This means 40 must be present in one of the leaves (specifically, as the first key of the right leaf L2 in standard implementations).
Step 3: Evaluate the options:
A: 40 is in L2. Valid.
B: 40 is in L2. Valid.
C: 40 is missing from both leaves. L2 starts at 50. This violates the rule.
D: 40 is in L2. Valid.
Step 4: Option C is impossible because the separator key 40 is not present in the leaf level.
Answer: C
Question 6 · Database Management and WarehousingMCQ
Which of the following is IMPOSSIBLE for a non-leaf internal node in a B+ tree of order p=5 (assuming it is not the root)?
A.
It contains 2 search keys and 3 tree pointers.
B.
It contains 4 search keys and 5 tree pointers.
C.
It contains 3 search keys and 4 tree pointers.
D.
It contains 5 search keys and 6 tree pointers.
Correct Answer:
D
Step-by-Step Solution
Key idea: This is a boundary case question about B+ tree node capacities, recognizable by the need to identify which configuration violates the structural limits of a given order p.
Step 1: For a non-leaf node of order p=5, the maximum number of tree pointers is 5, and the maximum number of search keys is 5−1=4.
Step 2: The minimum number of tree pointers (for a non-root internal node) is ⌈5/2⌉=3, and the minimum number of search keys is 3−1=2.
Step 4: Option D violates the maximum capacity of p=5.
Answer: D
Question 7 · Database Management and WarehousingMCQ
A database system uses a block size of $2048$ bytes for its B+ tree index. The search key size is $16$ bytes, the data record pointer size is $8$ bytes, and the next-leaf pointer size is $8$ bytes. What is the maximum number of entries $p_{leaf}$ that can be stored in a leaf node?
A.
85
B.
86
C.
128
D.
127
Correct Answer:
A
Step-by-Step Solution
Key idea: This is a construction question requiring application of the leaf node fanout formula with careful attention to all pointer types.
Step 1: Recall the leaf node capacity formula:
pleaf×(V+Pd)+Pnext≤B
where V = key size, Pd = data pointer size, Pnext = next-leaf pointer size, B = block size
Step 2: Substitute the given values:
B=2048 bytes
V=16 bytes
Pd=8 bytes
Pnext=8 bytes
pleaf×(16+8)+8≤2048
Step 3: Solve for pleaf:
pleaf×24+8≤2048
pleaf×24≤2040
pleaf≤242040=85
Step 4: Take the floor (must be integer):
pleaf=⌊85⌋=85
Answer: A
Question 8 · Database Management and WarehousingNAT
A B+ tree non-leaf node is built with a block size of $1024$ bytes. The tree pointer size is $8$ bytes and the search key size is $10$ bytes. What is the maximum number of tree pointers this non-leaf node can hold?
Correct Answer:
57.00
Step-by-Step Solution
Key idea: This is a casework calculation question testing the non-leaf node fanout formula.
Step 1: Recall the non-leaf node capacity inequality. A node with p pointers has p−1 keys.
p×Ptr+(p−1)×V≤B
Step 2: Substitute the given values: B=1024, Ptr=8, V=10.
8p+10(p−1)≤1024
Step 3: Simplify and solve for p:
8p+10p−10≤1024
18p≤1034
p≤181034≈57.44
Step 4: Since p must be an integer, take the floor:
p=57
Answer: 57.00
Question 9 · Database Management and WarehousingMCQ
A B+ tree index is built with the following specifications:\\
\\
Block size: $2$ KB\\
Tree pointer size: $6$ bytes\\
Search key size: $10$ bytes\\
\\
What is the maximum number of tree pointers $p$ that can be stored in a non-leaf node?
A.
128
B.
129
C.
2
D.
1
Correct Answer:
A
Step-by-Step Solution
Key idea: This is a boundary-case question testing unit conversion and the non-leaf node fanout formula.
Step 1: Convert block size to bytes:
B=2 KB=2×1024=2048 bytes
Step 2: Recall the non-leaf node capacity formula:
p×Ptr+(p−1)×V≤B
where Ptr = tree pointer size, V = search key size
Step 3: Substitute the values:
B=2048 bytes
Ptr=6 bytes
V=10 bytes
p×6+(p−1)×10≤2048
Step 4: Simplify and solve:
6p+10p−10≤2048
16p≤2058
p≤162058=128.625
Step 5: Take the floor:
p=⌊128.625⌋=128
Answer: A
Question 10 · Database Management and WarehousingMCQ
In a B+ tree, if a non-leaf internal node has a maximum of p tree pointers, how many search keys does it contain?
A.
p−1
B.
p
C.
p+1
D.
2p
Correct Answer:
A
Step-by-Step Solution
Key idea: This is a direct structural definition question for B+ trees.
Step 1: Recall the structure of a non-leaf node in a B+ tree. It acts as a routing guide.
Step 2: A node with p pointers separating different key ranges must have exactly p−1 search keys to define those boundaries.
Step 3: Therefore, the number of search keys is p−1.