GateAI
File Organization and Indexing

GATE CSE 2023 · Q62

NAT2 marksMedium

Time

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 bb blocks takes ⌈log⁡2b⌉\lceil \log_2 b \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 ________.

GATE CSE 2023 Q62 diagram

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 6

File Organization and Indexing

To find the number of block accesses required to identify the target block in the data file, we determine the number of blocks bb in the primary index file:

  1. Data file blocks:

    • Record size, R=100 bytesR = 100\text{ bytes}

    • Block size, B=1024 bytesB = 1024\text{ bytes}

    • Blocking factor for data file (records per block), Bfr=⌊1024/100⌋=10 records/blockBfr = \lfloor 1024 / 100 \rfloor = 10\text{ records/block}

    • Total data records, N=25000N = 25000

    • Number of data blocks, Bdata=⌈25000/10⌉=2500 blocksB_{\text{data}} = \lceil 25000 / 10 \rceil = 2500\text{ blocks}

  2. Primary index file blocks:

    • A primary index has one entry for each data block (sparse index).

    • Total index entries, Nindex=Bdata=2500N_{\text{index}} = B_{\text{data}} = 2500

    • Index entry size, Ri=Primary key size+Block pointer size=15+5=20 bytesR_i = \text{Primary key size} + \text{Block pointer size} = 15 + 5 = 20\text{ bytes}

    • Index blocking factor (entries per index block), Bfri=⌊1024/20⌋=51 entries/blockBfr_i = \lfloor 1024 / 20 \rfloor = 51\text{ entries/block}

    • Total index blocks, b=⌈2500/51⌉=⌈49.0196⌉=50 blocksb = \lceil 2500 / 51 \rceil = \lceil 49.0196 \rceil = 50\text{ blocks}

  3. Worst-case block accesses to identify the data block:

    • Searching the index file using binary search takes ⌈log⁡2b⌉\lceil \log_2 b \rceil block accesses.

    • Accesses =⌈log⁡250⌉=6= \lceil \log_2 50 \rceil = 6

Thus, the number of block accesses required to identify the block in the data file is 6.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This File Organization and Indexing previous year question is Q62 of the GATE CSE 2023 paper. Find more GATE CSE PYQs on File Organization and Indexing in Databases, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related File Organization and Indexing PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

File Organization and Indexing in GATE CSE

File Organization and Indexing has 17 GATE CSE PYQs across 17 papers from 2011 to 2026. 5 of them are 2-mark NAT questions like this one, and it is the only one in GATE CSE 2023.

How GATE tests File Organization and Indexing

More from GATE CSE 2023

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2023 · Q62 · NAT

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 b blocks takes ⌈ log2 b ⌉ 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 …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.