Skip to content
Official PYQ · 2021

GATE CS 2021 Set 2 Q21 — File Organization and Indexing (B and B+ Trees)

Explain with AI
A data file consisting of 1,50,0001,50,000 student-records is stored on a hard disk with block size of 40964096 bytes. The data file is sorted on the primary key RollNo\textrm{RollNo}. The size of a record pointer for this disk is 77 bytes. Each student-record has a candidate key attribute called ANum\textrm{ANum} of size 1212 bytes. Suppose an index file with records consisting of two fields, ANum\textrm{ANum} value and the record pointer 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 ________
View worked solution

Answer: 698 : 698

To find the number of blocks required for the index file, we need to determine the type of index, the size of each index record, and the number of index records that can fit in a single block.

1. Determine the Type of Index

  • The data file is sorted on the primary key RollNo\textrm{RollNo}.
  • The index is built on ANum\textrm{ANum}, which is a candidate key (non-ordering key).
  • An index on a non-ordering key is a Secondary Index. Since it is a secondary index, it must be a dense index (i.e., there is one index entry for every record in the data file).
  • Therefore, the total number of index records (NN) = 1,50,0001,50,000.

2. Calculate the Index Record Size

Each index record consists of the candidate key ANum\textrm{ANum} and a record pointer:

Index Record Size (Ri)=Size of ANum+Size of Record Pointer\text{Index Record Size } (R_i) = \text{Size of } \textrm{ANum} + \text{Size of Record Pointer} Ri=12 bytes+7 bytes=19 bytesR_i = 12\text{ bytes} + 7\text{ bytes} = 19\text{ bytes}

3. Calculate the Blocking Factor of the Index File

Since the records cannot be split across disk blocks (unspanned organization), the number of index records per block (BfrB_{fr}) is:

Bfr=⌊Block SizeRi⌋=⌊409619⌋=⌊215.58⌋=215 records/blockB_{fr} = \left\lfloor \frac{\text{Block Size}}{R_i} \right\rfloor = \left\lfloor \frac{4096}{19} \right\rfloor = \lfloor 215.58 \rfloor = 215 \text{ records/block}

4. Calculate the Number of Blocks for the Index File

The total number of blocks required is:

Number of Blocks=⌈Total Index RecordsBfr⌉=⌈1,50,000215⌉=⌈697.67⌉=698\text{Number of Blocks} = \left\lceil \frac{\text{Total Index Records}}{B_{fr}} \right\rceil = \left\lceil \frac{1,50,000}{215} \right\rceil = \lceil 697.67 \rceil = 698

Thus, the number of blocks in the index file is 698.

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