Question

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=2101\text{K}=2^{10}

Official answer and solution
Official answer
3
From
Official GATE 2026 answer key

Solution

Allocate P1 (16 KB) and P2 (9 KB) using Best-Fit and count the remaining non-zero holes strictly smaller than 8 KB.

Initial holes: 20,4,25,18,7,9,15,1220, 4, 25, 18, 7, 9, 15, 12 KB.

  1. P1 (16 KB) arrives: Under Best-Fit, the smallest hole ≥16 KB\ge 16\text{ KB} is the 18 KB18\text{ KB} hole, leaving a leftover hole of size 18−16=2 KB18 - 16 = 2\text{ KB}.
  2. P2 (9 KB) arrives: The smallest hole ≥9 KB\ge 9\text{ KB} is the 9 KB9\text{ KB} hole, which is used completely (9−9=0 KB9 - 9 = 0\text{ KB}, no hole remains).

Remaining holes: 20,4,25,2,7,15,1220, 4, 25, 2, 7, 15, 12 KB.
The holes with size <8 KB< 8\text{ KB} are 4 KB,2 KB,4\text{ KB}, 2\text{ KB}, and 7 KB7\text{ KB}, which gives a total of 33 holes.

Final answer

3

Common trap

Counting the completely filled 9 KB partition (0 KB remainder) as a hole.

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

Source

Paper
GATE 2026 Computer Science and Information Technology - Session 2 (CS2)
Question
55 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.