average = 1 - largestblock / total freemem counter
(2.1)
If you make enough allocation/deallocation requests, then the given algorithm
is sufficient to generate enough fragmentation. If you were to make 20 requests,then the beginning of the free list would be allocated, put back, and then the next request would be allocated from the new "beginning" of the free list since the leftover block would still be sufficiently big to house the next allocation request.
If you make enough allocation/deallocation requests, then the given algorithm is mostly correct. You just need to add an extra if statement that checks if that space was actually allocated or not. If not then you can't try to deallocate it.
You are essentially just chopping up the free list into a bunch of small blocks so this algorithm will work.
I used the pseudo-code given to me in the lab.
(3.2) For my simulation of allocating and deallocating, best fit results in the smallest average fragmentation percentage at only 61.19% compared to the other two methods which were in the low to mid 90s region. I think best fit worked the best because the program is already minimizing the amount of fragmentation by using the smallest block able to accomodate the request from the beginning.