A disk of size 512M bytes is divided into blocks of 64K bytes. A file is stored in the disk using linked allocation. In linked allocation, each data block reserves 4 bytes to store the pointer to the next data block. The link part of the last data block contains a NULL pointer (also of 4 bytes). Suppose a file of 1M bytes needs to be stored in the disk. Assume, 1K = 2^10 and 1M = 2^20. The amount of space in bytes that will be wasted due to internal fragmentation is ______. (Answer in integer)
GATE 2025 CS1 Q.51: solution and answer
Answer and solution
ANSWER
The space wasted due to internal fragmentation is 65468 bytes.
Official answer: 65468Source: Official answer key, GATE 2025 CS1 (IIT Roorkee)
Block size bytes. Each block reserves 4 bytes for the pointer (the last block holds a 4-byte NULL pointer), so each block holds bytes of file data.
File size bytes.
Blocks needed . Since , 16 blocks are not enough, so 17 blocks are needed.
The first 16 blocks hold bytes of data, so the last block holds only bytes of data.
Internal fragmentation is the unused data area of the last block: bytes. The 4-byte pointer field in the last block holds the NULL pointer, so it is used and not wasted.
Wasted space bytes.
KEY IDEA
Linked allocation loses 4 bytes of every block to the pointer, so a block holds 65532 data bytes. Internal fragmentation is the unused data area in the last block only.
WATCH OUT FOR
Using the full 65536 bytes as the data capacity (giving 17 blocks and 0 or wrong waste). Another slip is counting the last block's NULL pointer as wasted, or dividing the file by 65536 to get exactly 16 blocks.
From the GATE 2025 CS1 paper. Every question of this paper · Download the full paper · All 6 File systems & disks questions, with notes
More File systems & disks questions
- GATE 2020 CS Q.35 · MCQ · 2 marksConsider the following five disk access requests of the form (request id, cylinder number) that are present…
- GATE 2018 CS Q.53 · NAT · 2 marksConsider a storage disk with 4 platters (numbered as 0, 1, 2 and 3), 200 cylinders (numbered as 0, 1…
- GATE 2026 CS1 Q.59 · NAT · 2 marksConsider a hard disk with a rotational speed of 15000 rpm. The time to move the read/write head from a track…
