Question
a class called MemLinkedList. MemLinkedList will use nodes that store a flag (F or A) to represent a Free or Allocated block of memory, along
a class called MemLinkedList. MemLinkedList will use nodes that store a flag (F or A) to represent a Free or Allocated block of memory, along with the size of the block of memory. It should have the methods listed below. The methods should all operate on the object making the call (none are static).
Perform checking of the parameters and throw exceptions where appropriate.
The linked list should be as shown in the illustration.
It should not use sentinel nodes (empty header and tail nodes). You should strive for an efficient implementation of each method.
MAKE SURE YOU GOT THIS CONCEPT:
1 megabyte of free memory :
Head-->|F|1000K|-->tail
Requesting 100K of memory...
Head-->|A|100K|-->|F|900K|-->tail
Requesting 200K of memory...
Head-->|A|100K|-->|A|200K|-->|F|700K|-->tail
Releasing 100K of memory...
Head-->|F|300K|-->|F|700K|-->tail
Releasing 200K of memory...
Head-->|F|1000K|-->tail
Clearing the memory...
Head-->|F|1000K|-->tail
20 points each (a-e)
a. request(int size)
allocates a block of this size, receives a size in kilobytes
b. release(int size)
frees a block of this size (and repeatedly merges with free neighbors), receives a size in kilobytes
c. clear()
resets to the initial 1M free list
d. print()
prints each node's status (A or F) and size
e. main()
demonstrates each of your methods
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres the required program in JAVA PROGRAM class MemBlock char flag A for Allocated F for Free int sizeKB Size in kilobytes MemBlock next public MemBl...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started