Skip to content
Official PYQ · 2008

GATE CS 2008 Q70 — File Organization and Indexing (B and B+ Trees)

Explain with AI

Consider a file of 1638416384 records. Each record is 32  bytes32\;\text{bytes} long and its key field is of size 6  bytes6\;\text{bytes}. The file is ordered on a non-key field, and the file organization is unspanned. The file is stored in a file system with block size 1024  bytes1024\;\text{bytes}, and the size of a block pointer is 10  bytes10\;\text{bytes}. If the secondary index is built on the key field of the  file, and a multi-level index scheme is used to store the secondary index, the  number  of  first-level  and second-level  blocks  in  the  multi-level  index  are respectively

Choose one option
View worked solution

Answer: C

To find the number of blocks at each level of the multi-level secondary index, we proceed as follows:

  1. Identify the Index Type: Since a secondary index is built on a key field (which is not the ordering field of the file), it must be a dense index. This means there is one index entry for every record in the data file.
    Number of records = 1638416384
    Number of first-level index entries = 1638416384
  2. Calculate Index Entry Size (RiR_i): Ri=Key size+Block pointer size=6 bytes+10 bytes=16 bytesR_i = \text{Key size} + \text{Block pointer size} = 6\text{ bytes} + 10\text{ bytes} = 16\text{ bytes}
  3. Calculate Index Blocking Factor (BfriBfr_i): Bfri=⌊Block sizeRi⌋=⌊102416⌋=64 entries per blockBfr_i = \left\lfloor \frac{\text{Block size}}{R_i} \right\rfloor = \left\lfloor \frac{1024}{16} \right\rfloor = 64\text{ entries per block}
  4. Number of First-Level Blocks (b1b_1): b1=⌈Number of first-level entriesBfri⌉=⌈1638464⌉=256 blocksb_1 = \left\lceil \frac{\text{Number of first-level entries}}{Bfr_i} \right\rceil = \left\lceil \frac{16384}{64} \right\rceil = 256\text{ blocks}
  5. Number of Second-Level Blocks (b2b_2): The second level of a multi-level index is a sparse index containing one entry for each block of the first level.
    Number of second-level index entries = 256256 b2=⌈256Bfri⌉=⌈25664⌉=4 blocksb_2 = \left\lceil \frac{256}{Bfr_i} \right\rceil = \left\lceil \frac{256}{64} \right\rceil = 4\text{ blocks}

Thus, the number of first-level and second-level blocks are 256 and 4 respectively.

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