Skip to content
GATEiit

GATE CSE 2022 Q63: Disk accesses to insert a block mid-file: contiguous vs linked

Question

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 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 AA and BB are nAn_A and nBn_B, respectively, then the value of nA+nBn_A + n_B is_________.

Try it: numerical answer: type the value

Numerical answer. No negative marking.
Show answer and explanation

Answer: 153 (official GATE 2022 final answer key)

Concept used: Contiguous allocation must shift the later blocks; linked allocation must walk the list and fix one pointer.

First step: In A, blocks 51–100 are each read and written one place later, then the new block is written; in B, read blocks 1–50, write the new block, and rewrite block 50's pointer.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2022 CS question paper and final answer key, organised by IIT Kharagpur. Question paper · Answer key