Providing Solution For Lab Using Best Fit Algorithm profile

next fit and other techniques).

Select and simulate one of these techniques for lab4 and select another technique for lab5.


Memory is 256K.

Each unit is 2K. Therefore, there are 128 units that can be allocated to different processes.

A process may request between 3 and 10 units of memory

Number of requests: 10,000

Based on the above assumptions, three constants are defined in the code as follows:

#define NUM_REQUESTS 10000

#define MIN_NUM_UNITS 3

#define MAX_NUM_UNITS 10


A class is which has two member variables called process_id and num_units.

Also a list of nodes needs to be defined.

At start all the units are available. We can use -1 as the process_id to represent availability (hole). The the list at the start where the 128 units is available for allocation. Note however, a process can only ask for up to 10 units of allocation.

-1 128






The program uses a to randomly select between allocation and deallocations. The deallocations can happen if there is at least one process that memory is allocated for it.

You can keep track of the list of processes that the memory is currently being allocated to them. Then during the deallocation, you may randomly select one process from this list and deallocate memory for that process.


Each allocation or deallocation is considered as one request. You must also keep track of number of requests since we want to have 10,000 requests in this simulation.


Each process may request 3 to 10 units of memory. Therefore, number of unit requested by each process is a random number in the range 3 to 10. You may use a and at the end of each allocation request, you may increment that variable for the next process ID request.


You may use a for loop to check the list to see if there is a hole big enough for the given request as follows:

for (list<Node>::iterator cur = memory_list.begin(); cur != memory_list.end(); ++cur) {

As you check each node, if a node has a process id of -1 and the size of it is equal or greater than the requested number of units then allocation is possible.

You need to modify the list by inserting a node with the and given number of units requested.


If process 0 requests 5 units, then the above list becomes:


Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
The price is based on these factors:
Academic level
Number of pages
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
Need assignment help? You can contact our live agent via WhatsApp using +1 718 717 2861

Feel free to ask questions, clarifications, or discounts available when placing an order.
  +1 718 717 2861           + 44 161 818 7126           [email protected]
  +1 718 717 2861         [email protected]