chapter

    Indexing and B+ Trees Notes for Gate Da

    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

    1. High Fanout: Each node can hold hundreds of keys, drastically reducing the tree height (typically to 3 or 4 levels for millions of records).
    2. Balanced: All leaf nodes are at the exact same depth, guaranteeing predictable, worst-case search time.
    3. Data at Leaves Only: Internal nodes act purely as a "map" or routing guide. Only leaf nodes contain Data Record Pointers.
    4. 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 be the maximum number of tree pointers (fanout) in a non-leaf node, and be the maximum number of data entries in a leaf node.

    Node Type Pointer/Key Constraints Data Pointers?
    Root Min 2 pointers, Max pointers (if not a leaf). Only if it is the sole node.
    Internal Min pointers, Max pointers. Never. Contains only keys and block pointers.
    Leaf Min entries, Max 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 bytes. The tree pointer size is bytes, and the search key size is bytes. What is the maximum number of tree pointers 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 , which yields .

    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 (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 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.

    Explore complete test series, official past papers, and chapter-wise study tools.

    Why MastersUp

    Personalised first. High quality throughout.

    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

    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

    1. High Fanout: Each node can hold hundreds of keys, drastically reducing the tree height (typically to 3 or 4 levels for millions of records).
    2. Balanced: All leaf nodes are at the exact same depth, guaranteeing predictable, worst-case search time.
    3. Data at Leaves Only: Internal nodes act purely as a "map" or routing guide. Only leaf nodes contain Data Record Pointers.
    4. 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 be the maximum number of tree pointers (fanout) in a non-leaf node, and be the maximum number of data entries in a leaf node.

    Node Type Pointer/Key Constraints Data Pointers?
    Root Min 2 pointers, Max pointers (if not a leaf). Only if it is the sole node.
    Internal Min pointers, Max pointers. Never. Contains only keys and block pointers.
    Leaf Min entries, Max 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 () = 4096 bytes
    • Node Pointer Size () = 10 bytes
    • Search Key Size () = 11 bytes
    • Data Record Pointer Size = 12 bytes (Not used for non-leaf calculation)

    Objective: Find maximum node pointers () in a non-leaf node.

    Calculation:

    Result: The maximum integer value for is 195.

    Indexing and B+ Trees: Solved Questions with Step-by-Step Explanations (10 Problems)

    Question 1 · Database Management and Warehousing MCQ

    A B+ tree non-leaf node has a block size of bytes. The tree pointer size is bytes, and the search key size is bytes. What is the maximum number of tree pointers this node can hold?

    1. A.

      7

    2. B.

      6

    3. C.

      8

    4. 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: .

    Step 2: Substitute the given values: .

    Step 3: Simplify the inequality: .

    Step 4: Solve for : .

    Step 5: Since must be an integer, the maximum value is .

    Answer: 7

    Question 2 · Database Management and Warehousing MCQ

    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?

    1. A.

      42

    2. B.

      43

    3. C.

      41

    4. 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 be the max pointers. .

    Step 2: Simplify the inequality: .

    Step 3: Solve for : . Since must be an integer, max pointers .

    Step 4: The maximum number of search keys is .

    Answer: A

    Question 3 · Database Management and Warehousing MCQ

    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 , which yields .

    1. A.

      Both A and R are true and R is the correct explanation of A

    2. B.

      A is true but R is false

    3. C.

      Both A and R are true but R is NOT the correct explanation of A

    4. 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 1: Evaluate Assertion (A). Block size . , .

    Step 2: Apply the non-leaf formula: .

    Step 3: Maximum integer . Assertion (A) is TRUE.

    Step 4: Evaluate Reason (R). The reason claims the calculation uses . 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 Warehousing MCQ

    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?

    1. A.

      2

    2. B.

      3

    3. C.

      4

    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 , the minimum is .

    Step 3: Any leaf node must have between 3 and 5 entries. Therefore, 2 entries is impossible.

    Answer: A

    Question 5 · Database Management and Warehousing MCQ

    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?

    1. A.

      : [10, 20], : [40, 50]

    2. B.

      : [20, 30], : [40, 60]

    3. C.

      : [10, 30], : [50, 60]

    4. D.

      : [30], : [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 in standard implementations).

    Step 3: Evaluate the options:

    • A: 40 is in . Valid.
    • B: 40 is in . Valid.
    • C: 40 is missing from both leaves. starts at 50. This violates the rule.
    • D: 40 is in . 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 Warehousing MCQ

    Which of the following is IMPOSSIBLE for a non-leaf internal node in a B+ tree of order (assuming it is not the root)?

    1. A.

      It contains 2 search keys and 3 tree pointers.

    2. B.

      It contains 4 search keys and 5 tree pointers.

    3. C.

      It contains 3 search keys and 4 tree pointers.

    4. 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 .

    Step 1: For a non-leaf node of order , the maximum number of tree pointers is 5, and the maximum number of search keys is .

    Step 2: The minimum number of tree pointers (for a non-root internal node) is , and the minimum number of search keys is .

    Step 3: Evaluate the options:

    • A: 2 keys, 3 pointers. Valid (meets minimums).
    • B: 4 keys, 5 pointers. Valid (meets maximums).
    • C: 3 keys, 4 pointers. Valid (within bounds).
    • D: 5 keys, 6 pointers. Impossible (exceeds maximums).

    Step 4: Option D violates the maximum capacity of .

    Answer: D

    Question 7 · Database Management and Warehousing MCQ

    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?

    1. A.

      85

    2. B.

      86

    3. C.

      128

    4. 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:

    where = key size, = data pointer size, = next-leaf pointer size, = block size

    Step 2: Substitute the given values:

    • bytes
    • bytes
    • bytes
    • bytes

    Step 3: Solve for :

    Step 4: Take the floor (must be integer):

    Answer: A

    Question 8 · Database Management and Warehousing NAT

    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 pointers has keys.

    Step 2: Substitute the given values: , , .

    Step 3: Simplify and solve for :

    Step 4: Since must be an integer, take the floor:

    Answer: 57.00

    Question 9 · Database Management and Warehousing MCQ

    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?

    1. A.

      128

    2. B.

      129

    3. C.

      2

    4. 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:

    Step 2: Recall the non-leaf node capacity formula:

    where = tree pointer size, = search key size

    Step 3: Substitute the values:

    • bytes
    • bytes
    • bytes

    Step 4: Simplify and solve:

    Step 5: Take the floor:

    Answer: A

    Question 10 · Database Management and Warehousing MCQ

    In a B+ tree, if a non-leaf internal node has a maximum of tree pointers, how many search keys does it contain?

    1. A.

    2. B.

    3. C.

    4. D.

    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 pointers separating different key ranges must have exactly search keys to define those boundaries.

    Step 3: Therefore, the number of search keys is .

    Answer:

    More notes in this unit