chapter

    File Organization, Indexing and B+ Trees Pyqs for Gate Cs

    Solve 7+ File Organization, Indexing and B+ Trees previous year questions for GATE CS with answers and detailed solutions. Free sample questions below.

    Try a question

    Answer it here to see how it works. Nothing is recorded until you sign in.

    Question 1
    2026 Slot Set2 PYQ
    Level 3: Exam Standard
    An index in a DBMS is said to be dense if an index entry appears for every search-key value in the indexed file. Otherwise it is called a sparse index. Consider the following two statements.

    S1: A hash index must be a dense index
    S2: A tree index can be a sparse index

    Which one of the following options is correct?
    Question 2
    2025 Slot Set2 PYQ
    Level 3: Exam Standard
    In a - tree where each node can hold at most four key values, a root to leaf path consists of the following nodes:



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

    Assume that a pointer between keys and points to a subtree containing keys in , and that when a leaf is created, the smallest key in it is copied up into its parent.

    A record with key value 23 is inserted into the - tree.

    The smallest key value in the parent of the leaf that contains is __________. (Answer in integer)
    Question 3
    2025 Slot Set1 PYQ
    Level 3: Exam Standard
    Consider the following tree with 5 nodes, in which a node can store at most 3 key values. The value 23 is now inserted in the tree. Which of the following options(s) is/are CORRECT?

    612191437910131517202122
    Question 4
    2024 Slot Set2 PYQ
    Level 3: Exam Standard

    Which of the following file organizations is/are I/O efficient for the scan operation in DBMS?

    Question 5
    2024 Slot Set1 PYQ
    Level 3: Exam Standard

    In a B+ tree, the requirement of at least half-full (50%) node occupancy is relaxed for which one of the following cases?

    Question 6
    2023 PYQ
    Level 3: Exam Standard
    Consider a database of fixed-length records, stored as an ordered file. The database has 25,000 records, with each record being 100 bytes, of which the primary key occupies 15 bytes. The data file is block-aligned in that each data record is fully contained within a block. The database is indexed by a primary index file, which is also stored as a block-aligned ordered file. The figure below depicts this indexing scheme.

    Index FileBlock AnchorPrimary KeyBlockPointerData FilePrimary Key(15 Bytes)Other Fields(85 Bytes)⋮⋮⋮⋮⋮⋮

    Suppose the block size of the file system is 1024 bytes, and a pointer to a block occupies 5 bytes. The system uses binary search on the index file to search for a record with a given key. You may assume that a binary search on an index file of blocks takes block accesses in the worst case.
    Given a key, the number of block accesses required to identify the block in the data file that may contain a record with the key, in the worst case, is __________.
    Question 7
    2021 Slot Set2 PYQ
    Level 3: Exam Standard

    A data file consisting of 1,50,000 student-records is stored on a hard disk with block size of 4096 bytes. The data file is sorted on the primary key RollNo. The size of a record pointer for this disk is 7 bytes. Each student-record has a candidate key attribute called ANum of size 12 bytes. Suppose an index file with records consisting of two fields, ANum value and the record pointer to the corresponding student record, is built and stored on the same disk. Assume that the records of data file and index file are not split across disk blocks. The number of blocks in the index file is __________.

    Free preview ends here

    Login to view the complete previous-year questions and solutions

    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.

    File Organization, Indexing and B+ Trees PYQs for GATE CS

    Solve 7+ File Organization, Indexing and B+ Trees previous year questions for GATE CS with answers and detailed solutions. Free sample questions below.

    B+ Tree Insertion, Splitting and Occupancy

    Databases › File Organization, Indexing and B+ Trees

    B+ Tree Mechanics

    Mastering insertion, splitting, and balance.

    What you will learn here
    1
    The step-by-step algorithm for inserting keys into leaf and internal nodes.
    2
    How node splitting works and how the middle key propagates upward.
    3
    Occupancy constraints: why nodes must be at least half full.

    B+ Tree Structure and Order

    B+ Tree Structure and Order

    1. The Order ()

    Defines node capacity. A node has at most child pointers and keys. Note: Verify if the problem specifies "max keys" or "max pointers".

    2. Balanced Property

    All leaf nodes are at the same depth. This guarantees consistent search time for any key.

    3. Leaf vs Internal Nodes

    Internal Nodes: Contain keys and child pointers. Act as an index.

    Leaf Nodes: Contain keys and data pointers. Linked for range queries.

    Key Insight: Because internal nodes do not store data pointers, they can hold more keys per block, reducing the tree height.

    File Organization, Indexing and B+ Trees: Solved Questions with Step-by-Step Explanations (7 Problems)

    Question 1 · Databases · 2026_Set2 MCQ
    An index in a DBMS is said to be dense if an index entry appears for every search-key value in the indexed file. Otherwise it is called a sparse index. Consider the following two statements.

    S1: A hash index must be a dense index
    S2: A tree index can be a sparse index

    Which one of the following options is correct?
    1. A.

      Both S1 and S2 are true

    2. B.

      Both S1 and S2 are false

    3. C.

      S1 is true and S2 is false

    4. D.

      S1 is false and S2 is true

    Correct Answer:

    A

    Step-by-Step Solution

    Insight: Hash indices are unordered and require an entry for every key to locate records (dense), whereas B+ trees are ordered and can act as a sparse primary index if the file is ordered by the same key.

    Exam route: Evaluate S1: Hash index lacks order, so sparse indexing (which relies on file order) is impossible. Thus, S1 is true. Evaluate S2: A B+ tree index can be clustered (primary) and sparse, storing only the first key of each data block. Thus, S2 is true. Both are true.

    Learning route:

    1. Dense index: entry for every search key.
    2. Sparse index: entry for only some keys (e.g., one per block), strictly requires the data file to be physically sorted on the index key.
    3. S1 (Hash index): A hash function computes a bucket address directly. It does not maintain search keys in sorted order. Therefore, you cannot skip keys or point to block anchors. Every search key must have its own entry. S1 is true.
    4. S2 (B+ tree index): A B+ tree maintains keys in sorted order. If built on the ordering key of a sequentially sorted file, it acts as a primary index. It can be implemented as a sparse index where internal nodes or leaf entries point to data blocks rather than individual records. S2 is true.

    Conclusion: Both S1 and S2 are true.

    Question 2 · Databases · 2025_Set2 NAT
    In a - tree where each node can hold at most four key values, a root to leaf path consists of the following nodes:



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

    Assume that a pointer between keys and points to a subtree containing keys in , and that when a leaf is created, the smallest key in it is copied up into its parent.

    A record with key value 23 is inserted into the - tree.

    The smallest key value in the parent of the leaf that contains is __________. (Answer in integer)
    Correct Answer:

    33.00

    Step-by-Step Solution

    Insight: Inserting 23 overflows the leaf, copying 23 to the parent, which then overflows and splits, leaving 33 as the smallest key in the new right parent node.

    Exam route: Leaf C (20, 22, 25, 26) + 23 splits to (20, 22) and (23, 25, 26). Copy 23 to B. B (7, 19, 33, 44) + 23 (7, 19, 23, 33, 44). Split B: median is 23. Right node gets (33, 44). Smallest key is 33.

    Learning route:

    1. Identify constraints: "at most four key values" means max keys = 4, so order (max 5 pointers).
    2. Locate leaf: Value 23 falls between 19 and 33, so it goes to leaf C: [20, 22, 25, 26].
    3. Handle leaf overflow: Insert 23 [20, 22, 23, 25, 26]. Split into Left (first keys [20, 22]) and Right (remaining keys [23, 25, 26]).
    4. Update parent: Copy the smallest key of the Right leaf (23) to parent B.
    5. Handle internal overflow: Parent B becomes [7, 19, 23, 33, 44]. This exceeds the max of 4 keys.
    6. Split internal node: The median is the rd key, which is 23. This key is moved to the grandparent (A).
    7. Form new nodes: The left internal node keeps keys left of 23: [7, 19]. The right internal node takes keys right of 23: [33, 44].
    8. Answer the specific question: The leaf containing 25* is the new right leaf [23, 25, 26]. Its parent is the new right internal node [33, 44]. The smallest key in this parent is 33.
    Question 3 · Databases · 2025_Set1 MSQ
    Consider the following tree with 5 nodes, in which a node can store at most 3 key values. The value 23 is now inserted in the tree. Which of the following options(s) is/are CORRECT?

    612191437910131517202122
    1. A.

      None of the nodes will split.

    2. B.

      At least one node will split and redistribute.

    3. C.

      The total number of nodes will remain same.

    4. D.

      The height of the tree will increase.

    Correct Answer:

    ["D"]

    Step-by-Step Solution

    Insight: Inserting 23 overflows the rightmost leaf, propagating an overflow to the root, forcing a root split and increasing the tree height.

    Exam route: Leaf 4 (20, 21, 22) + 23 splits into (20, 21) and (22, 23). Separator 22 goes to root. Root (6, 12, 19) + 22 (6, 12, 19, 22) overflows. Root splits, height increases.

    Learning route:

    1. Identify constraints: Max 3 key values means order (max 4 pointers, 3 keys).
    2. Locate leaf: Value 23 is , so it goes to the rightmost leaf: [20, 21, 22].
    3. Handle leaf overflow: Insert 23 [20, 21, 22, 23]. Split into Left (first keys [20, 21]) and Right (remaining keys [22, 23]).
    4. Update parent: Copy the smallest key of the Right node (22) to the root.
    5. Handle internal overflow: Root becomes [6, 12, 19, 22]. This exceeds the max of 3 keys. The median key (the nd key, which is 12) is moved to a new root.
    6. Result: The tree height increases from 2 to 3. The total number of nodes increases from 5 to 8. Standard B+ tree insertion uses splitting, not redistribution.
    Question 4 · Databases · 2024_Set2 MSQ

    Which of the following file organizations is/are I/O efficient for the scan operation in DBMS?

    1. A.

      Sorted

    2. B.

      Heap

    3. C.

      Unclustered tree index

    4. D.

      Unclustered hash index

    Correct Answer:

    ["A","B"]

    Step-by-Step Solution

    Insight: A full scan reads all blocks sequentially. Heap and Sorted files store records contiguously, making them I/O efficient for scans. Unclustered indices scatter records, causing random I/O.

    Exam route:

    • Sorted: Blocks are contiguous, sequential read is efficient.
    • Heap: Blocks are contiguous, sequential read is efficient.
    • Unclustered tree/hash: Pointers scatter records across disk, causing random block accesses for a full scan.

    Learning route:

    1. Scan operation means reading all or most records in the file.
    2. The I/O cost of a full scan depends on how records are physically laid out on disk.
    3. Heap files store records in insertion order. Blocks are allocated contiguously, so a full scan requires exactly sequential block transfers.
    4. Sorted files store records in search-key order. Blocks are also contiguous, so a full scan also requires sequential block transfers.
    5. Unclustered tree or hash indices store records based on index keys, meaning records with consecutive index keys might be in completely different, non-adjacent disk blocks. A full scan using these indices would require random I/O to fetch scattered blocks, which is highly inefficient.
    6. Thus, only Heap and Sorted are I/O efficient for the scan operation.

    Conclusion: Sorted and Heap.

    Question 5 · Databases · 2024_Set1 MCQ

    In a B+ tree, the requirement of at least half-full (50%) node occupancy is relaxed for which one of the following cases?

    1. A.

      Only the root node

    2. B.

      All leaf nodes

    3. C.

      All internal nodes

    4. D.

      Only the leftmost leaf node

    Correct Answer:

    A

    Step-by-Step Solution

    Insight: The root node of a B+ tree is exempt from the minimum occupancy rule because it naturally shrinks as entries are deleted.

    Exam route: In a B+ tree, internal and leaf nodes must be at least half full to maintain balance and efficiency. The root node is the only exception; it can have as few as one key (or zero if the tree is empty).

    Learning route:

    1. B+ tree nodes have a maximum capacity (order ) and a minimum fill factor (occupancy).
    2. To prevent the tree from becoming sparse and deep, all leaf and internal nodes must be at least keys full.
    3. The root node is a special exception. If the tree has only one node (which is the root and a leaf), it can have just 1 key. Even if the tree grows and then shrinks, the root is allowed to drop below the 50% occupancy threshold rather than forcing an immediate complex merge operation.
    4. Therefore, the 50% occupancy requirement is relaxed only for the root node.

    Conclusion: Only the root node.

    Question 6 · Databases · 2023 NAT
    Consider a database of fixed-length records, stored as an ordered file. The database has 25,000 records, with each record being 100 bytes, of which the primary key occupies 15 bytes. The data file is block-aligned in that each data record is fully contained within a block. The database is indexed by a primary index file, which is also stored as a block-aligned ordered file. The figure below depicts this indexing scheme.

    Index FileBlock AnchorPrimary KeyBlockPointerData FilePrimary Key(15 Bytes)Other Fields(85 Bytes)⋮⋮⋮⋮⋮⋮

    Suppose the block size of the file system is 1024 bytes, and a pointer to a block occupies 5 bytes. The system uses binary search on the index file to search for a record with a given key. You may assume that a binary search on an index file of blocks takes block accesses in the worst case.
    Given a key, the number of block accesses required to identify the block in the data file that may contain a record with the key, in the worst case, is __________.
    Correct Answer:

    6.00

    Step-by-Step Solution

    Insight: A primary index has one entry per data block. Calculate data blocks, then index blocks, then apply binary search cost. Do not add 1 for the data block access unless the question asks to "access the record".

    Exam route:

    1. Data blocks = .
    2. Index entries = 2500 (sparse primary index).
    3. Index block size = 1024. Entry size = 15 + 5 = 20.
    4. Index blocks = .
    5. Binary search on 50 blocks = accesses.

    Learning route:

    1. Blocking factor (data) = records/block.
    2. Total data blocks = blocks.
    3. Since it's a primary index on an ordered file, it is sparse. One index entry per data block. Total index entries = 2500.
    4. Index record size = 15 (key) + 5 (pointer) = 20 bytes.
    5. Blocking factor (index) = entries/block.
    6. Total index blocks = blocks.
    7. Worst-case binary search on 50 blocks = block accesses.
    8. The question asks for block accesses to "identify the block in the data file". This is achieved purely by searching the index file. Reading the data block itself would be an additional access, but it is not required to identify the block.

    Conclusion: 6 accesses.

    Question 7 · Databases · 2021_Set2 NAT

    A data file consisting of 1,50,000 student-records is stored on a hard disk with block size of 4096 bytes. The data file is sorted on the primary key RollNo. The size of a record pointer for this disk is 7 bytes. Each student-record has a candidate key attribute called ANum of size 12 bytes. Suppose an index file with records consisting of two fields, ANum value and the record pointer to the corresponding student record, is built and stored on the same disk. Assume that the records of data file and index file are not split across disk blocks. The number of blocks in the index file is __________.

    Correct Answer:

    698.00

    Step-by-Step Solution

    Insight: The index is built on a candidate key (ANum), but the file is sorted on a different key (RollNo). Thus, it is a secondary index and MUST be dense.

    Exam route:

    1. Secondary index dense 1 entry per record = 150,000 entries.
    2. Entry size = 12 + 7 = 19 bytes.
    3. Blocking factor = .
    4. Index blocks = .

    Learning route:

    1. Identify index type: The data file is sorted on RollNo, but the index is on ANum. This makes it a secondary index.
    2. Density rule: A secondary index must be dense because the file is not ordered by ANum. You cannot skip records. Thus, there is one index entry for every single student record. Total entries = 150,000.
    3. Index record size = ANum size (12 bytes) + record pointer (7 bytes) = 19 bytes.
    4. Index blocking factor = entries per block.
    5. Total index blocks = blocks.

    Conclusion: 698 blocks.

    More previous year questions (pyqs) in this unit