Skip to content
Official PYQ · 2023

GATE CS 2023 Q52 — File Organization and Indexing (B and B+ Trees)

Explain with AI

Consider a database of fixed-length records, stored as an ordered file. The database has 25,00025,000 records, with each record being 100100 bytes, of which the primary key occupies 1515 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.

Suppose the block size of the file system is 10241024 bytes, and a pointer to a block occupies 55 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 bb blocks takes ⌈log⁡2b⌉\left\lceil\log _{2} b\right\rceil 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 _____________.

View worked solution

Answer: 6

To find the number of block accesses required to identify the target data block, we first determine the structure of the data and index files:

  1. Data File Blocks:
    • Number of records per data block = ⌊Block SizeRecord Size⌋=⌊1024100⌋=10\lfloor \frac{\text{Block Size}}{\text{Record Size}} \rfloor = \lfloor \frac{1024}{100} \rfloor = 10 records.
    • Total data blocks (BdB_d) = ⌈2500010⌉=2500\lceil \frac{25000}{10} \rceil = 2500 blocks.
  2. Index File Blocks:
    • Since a primary index is a sparse index, it contains one entry per data block. Thus, there are 25002500 index entries.
    • Size of each index entry = Key Size+Block Pointer Size=15+5=20\text{Key Size} + \text{Block Pointer Size} = 15 + 5 = 20 bytes.
    • Number of index entries per block = ⌊102420⌋=51\lfloor \frac{1024}{20} \rfloor = 51 entries.
    • Total blocks in the index file (bb) = ⌈250051⌉=50\lceil \frac{2500}{51} \rceil = 50 blocks.

The worst-case number of block accesses to search the index file using binary search is:

⌈log⁡2b⌉=⌈log⁡250⌉=6\lceil \log_2 b \rceil = \lceil \log_2 50 \rceil = 6

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