CS FundamentalsHardGATE CS (PYQ pattern)

A file of 100,000 records of 120 bytes is stored in 4096-byte blocks, each with an 8-byte header (records do not span blocks), sorted on the key. A sparse primary index has one entry (12-byte key + 8-byte block pointer) per data block, and index blocks are 4096 bytes with no header. Using binary search on the index and then one data-block read, what is the worst-case number of block accesses to find a record by key?

  1. A. 6
  2. B. 12
  3. C. 5
  4. D. 7

Correct answer: C. 5

Blocking factor = floor(4088/120) = 34, so 2942 data blocks. Index entries per block = 204, so the sparse index has 15 blocks; binary search needs ceil(log2 15) = 4 reads, plus 1 data block = 5. Binary search on the data alone would need 12.

More DBMS and SQL questions

Exams that ask this topic