GATE / CS ARCHIVE

GATE CSE 1994 / QUESTION 1.24

First fit versus best fit

Operating Systems · Memory Allocation & Segmentation · Full GATE CSE 1994 paper

GATE 1994, Q1.24 MCQ
Report issue

Memory Allocation & Segmentation

Question 1.24, GATE 1994: The pictured heap has allocated lengths 50,300,600 separating free holes of lengths 150 and 350. Can requests 300,25,125,50 be satisfied by first fit, best fit, both or neither?
Tap to enlarge
Your answer
Answer & solution

Answer: B: first fit but not best fit (no official key was published)

Both policies allocate the first request in the 350 hole, leaving free lengths [150,50]. First fit places 25 in the first hole, leaving [125,50], then 125 there, leaving [0,50], and finally fits 50. Best fit places 25 in the 50 hole, leaving [150,25], then 125 in the 150 hole, leaving [25,25]. The final 50 fits neither hole, though total free space is 50. Hence only first fit succeeds.

Original paper, page 3