Question

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=210\text{1K} = 2^{10} and 1M=220\text{1M} = 2^{20}. The amount of space in bytes that will be wasted due to internal fragmentation is ______. (Answer in integer)

Official answer and solution
Official answer
65468
From
Official GATE 2025 answer key

Solution

Compute the usable data capacity per disk block (64 KB−4 B64\text{ KB} - 4\text{ B}), find how many blocks the 1 MB1\text{ MB} file requires, and compute the unused data bytes in the last block.

  1. Block size and usable payload per block:
    • Block size =64 KB=64×1024=65,536= 64\text{ KB} = 64 \times 1024 = 65,536 bytes.
    • Each block reserves 44 bytes for the link pointer, so usable data bytes per block =65,536−4=65,532= 65,536 - 4 = 65,532 bytes.
  2. Number of blocks required for a 1 MB1\text{ MB} file:
    • File size =1 MB=220=1,048,576= 1\text{ MB} = 2^{20} = 1,048,576 bytes.
    • The first 1616 blocks hold 16×65,532=1,048,51216 \times 65,532 = 1,048,512 bytes of file data.
    • The remaining 1,048,576−1,048,512=641,048,576 - 1,048,512 = 64 bytes of the file are stored in the 17th block.
  3. Internal fragmentation in the 17th (last) block:
    • Out of the 65,53265,532 usable data bytes in the 17th block (since 4 bytes are used by the NULL pointer), only 6464 bytes are occupied by the file:
Wasted space=65,532−64=65,468 bytes\text{Wasted space} = 65,532 - 64 = 65,468\text{ bytes}
Final answer

65468

Common trap

Forgetting to subtract the 4-byte NULL pointer in the 17th block (which would give 65536−64=6547265536 - 64 = 65472).

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2025 Computer Science and Information Technology - Session 1 (CS1)
Question
51 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.