GateAI
File Systems

GATE CSE 2022 · Q63

NAT2 marksMedium

Time

Consider two files systems AA and BB, that use contiguous allocation and linked allocation, respectively. A file of size 100 blocks is already stored in A and also in B. Now, consider inserting a new block in the middle of the file (between 50th50^{\text{th}} and 51st51^{\text{st}} block), whose data is already available in the memory. Assume that there are enough free blocks at the end of the file and that the file control blocks are already in memory. Let the number of disk accesses required to insert a block in the middle of the file in AA and BB are nAn_A and nBn_B, respectively, then the value of nA+nBn_A + n_B is ________.

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 153

File Systems

1. Contiguous Allocation (AA):

  • To insert a block between the 50th50^{\text{th}} and 51st51^{\text{st}} block, the remaining 50 blocks (blocks 51 to 100) must be shifted by one position.

  • Reading 50 blocks from disk: 50 disk reads.

  • Writing 50 shifted blocks to disk: 50 disk writes.

  • Writing the new block (at the 51st51^{\text{st}} position) to disk: 1 disk write.

nA=50+50+1=101n_A = 50 + 50 + 1 = 101

2. Linked Allocation (BB):

  • To reach the 50th50^{\text{th}} block to update its pointer, traverse the linked list starting from block 1: 50 disk reads.

  • Write the modified 50th50^{\text{th}} block back to disk: 1 disk write.

  • Write the newly inserted block to disk (pointing to the 51st51^{\text{st}} block): 1 disk write.

nB=50+1+1=52n_B = 50 + 1 + 1 = 52

Thus, the total number of disk accesses is:

nA+nB=101+52=153n_A + n_B = 101 + 52 = 153

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 Systems previous year question is Q63 of the GATE CSE 2022 paper. Find more GATE CSE PYQs on File Systems in Operating Systems, 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 Systems 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 Systems in GATE CSE

File Systems has 14 GATE CSE PYQs across 14 papers from 2011 to 2026. 7 of them are 2-mark NAT questions like this one, and it is the only one in GATE CSE 2022.

How GATE tests File Systems

More from GATE CSE 2022

Share this solution

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

GateAI solution cardGATE CSE 2022 · Q63 · NAT

Consider two files systems A and B, that use contiguous allocation and linked allocation, respectively. A file of size 100 blocks is already stored in A and also in B. Now, consider inserting a new block in the middle of the file (between 50th and 51st block), whose data is already available in the memory. Assume that there are enough free blocks at the end of the file and that the file control blocks are already in memory. Let the number of disk accesses required to insert a block in the middle of the file in A and B are nA and nB, respectively, then the value of nA + nB 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.