IAE Academy

GATE 2025 CS1 Q.51: solution and answer

GATE 2025 · CS1Q.51 · 2 marks · NAT

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)

See the question in the paper

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)

  1. 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.

  2. File size bytes.

  3. Blocks needed . Since , 16 blocks are not enough, so 17 blocks are needed.

  4. The first 16 blocks hold bytes of data, so the last block holds only bytes of data.

  5. 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.

  6. 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