Question:medium

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

Note: \(1\text{K}=2^{10}\)

Show Hint

Use best fit: pick the smallest hole that still fits the process, split off the leftover as a new smaller hole, and remove a hole completely if the process fits it exactly.
Updated On: Jul 22, 2026
Show Solution

Correct Answer: 3

Solution and Explanation

Step 1: Set the rule for best fit.
Best fit always picks the tightest hole, the smallest one that can still hold the incoming process. Starting holes: $20, 4, 25, 18, 7, 9, 15, 12$ (all in KB).

Step 2: Fit P1, which needs 16 KB.
Holes big enough for 16 KB are $20, 25, 18$. The tightest of these is $18$. Placing P1 there leaves a stub of $18-16=2$ KB in place of the old 18 KB hole.
Updated list: $20, 4, 25, 7, 9, 15, 12, 2$.

Step 3: Fit P2, which needs 9 KB.
Holes big enough for 9 KB are $20, 25, 9, 15, 12$. The tightest is $9$, an exact match, so this hole is used up completely and vanishes from the list.
Updated list: $20, 4, 25, 7, 15, 12, 2$.

Step 4: Sort by size and mark the small ones.
Writing the list in order: $2, 4, 7, 12, 15, 20, 25$. The values under 8 KB are $2, 4, 7$, which is $3$ holes.
\[ \boxed{3} \]
Was this answer helpful?
0


Questions Asked in GATE CS exam