Question
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.
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 the record is _______.
Official answer and solution
- Official answer
- 6
- From
- Official GATE 2023 answer key
Solution
Determine the blocking factors of data and index files, then compute worst-case binary search block accesses.
-
Data File:
- Block size = , Record size = .
- Unspanned blocking factor: .
- Total data blocks: .
-
Primary Index File:
- A primary index has one index entry per data block (sparse index): index entries.
- Each index entry contains a primary key () and a block pointer (): .
- Index blocking factor: .
- Total index blocks: .
-
Binary Search Accesses:
- Worst-case block accesses to locate the entry in the index file:
- Worst-case block accesses to locate the entry in the index file:
6
Adding 1 for accessing the data block, whereas the question explicitly asks for block accesses required to 'identify the block in the data file' (i.e., searching within the index file).
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2023 Computer Science and Information Technology (CS)
- Question
- 62 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.