IAE Academy

GATE 2026 CS2 Q.55: solution and answer

GATE 2026 · CS2Q.55 · 2 marks · NAT

Consider contiguous allocation of physical memory to processes using variable partitioning scheme. Suppose there are 8 holes in the memory of sizes 20 KB, 4 KB, 25 KB, 18 KB, 7 KB, 9 KB, 15 KB, and 12 KB. Assume that no two holes are adjacent. Two processes P1 of size 16 KB and P2 of size 9 KB arrive in that order, and they are allocated memory using the best-fit technique. After allocating space to P1 and P2, the number of holes of size less than 8 KB is ____________. (answer in integer)

Note: 1K=2^10

See the question in the paper

Answer and solution

ANSWER

The number of holes smaller than 8 KB is 3.

Official answer: 3Source: Official answer key, GATE 2026 CS2 (IIT Guwahati)

  1. Best fit allocates each process to the smallest hole that is large enough for it.

  2. P1 needs . The holes of at least are . The smallest is , so P1 goes there and leaves a hole of .

  3. The holes are now (in ).

  4. P2 needs . The holes of at least are . The smallest is exactly , so P2 fills it completely and no leftover hole remains.

  5. The holes are now (7 holes).

  6. The holes smaller than are . The count is .

KEY IDEA

Best fit takes the smallest hole that is big enough. An exact fit leaves no hole behind, while a larger hole leaves a remainder that becomes a new hole.

WATCH OUT FOR

Using first fit or worst fit would put P1 in the 20 KB or 25 KB hole. Another slip is leaving a zero-size hole after the exact fit of P2 and counting it. A third is forgetting that the 2 KB remainder from P1 is a new hole smaller than 8 KB.

From the GATE 2026 CS2 paper. Every question of this paper · Download the full paper · All 10 Memory management questions, with notes

More Memory management questions