7/34
Part 2 of 7 · The free listLearn and do
First fit takes the lowest run with room, not the smallest
First fit walks the runs in order and stops at the first one with at least n units:
def first_fit(free, n):
for i, (start, end) in enumerate(free):
if end - start >= n:
return i
return None
Here it is on the free list above, then one more request under two rules.
The free list is [(3, 7), (9, 10)]. alloc(2) takes the front of (3, 7). Then alloc(1): what does first fit return, and what does best fit?
Pick an answer above to see the rest