A Chunklist is like a regular linked list, except each node contains a little fixed size array of elements instead of just a single
A Chunklist is like a regular linked list, except each node contains a little fixed size array of elements instead of just a single element. Each node also contains its own "size" int to know how full it is. The ChunkList will have the following features... The ChunkList object contains a head pointer to the first chunk, a tail pointer to the last chunk, and an int to track the logical size of the whole collection. When the size of the list is 0, the head and tail pointers are null. head tail size 16 next next * next next null size size e 1 size 2 size 5 values 4 values 9 values 10 values 2 2 12 7 5 4 -1 2 8 Each chunk contains a fixed size ItemType[] array, an int to track how full the chunk is, and a next pointer. There should be a constant ARRAY_SIZE = 8 that defines the fixed size of the array of each chunk. Elements should be added to the array starting at its 0 index. Elements in each little array should be kept in a contiguous block starting at 0 (this will require shifting elements around in the little array at times). You may want to test ARRAY_SIZE set to smaller values, but turn it in with ARRAY_SIZE set to 8. The empty collection should be implemented as null head and tail pointers. Only allocate chunks when actually needed. ChunkList should implement the following methods similar to those describe on pages 136-138: o MakeEmpty isFull > (refers to the entire list, not an individual chunk node) Getlength > (refers to the total number of element, not the number of chunk nodes) Getltem Putltem Deleteltem o Resetlist o GetNextitem The Putltem operation should add new elements at the end of the overall collection - i.e. new elements should always go into the tail chunk. If the tail chunk is full, a new chunk should be added and become the new tail. We are not going to trouble ourselves shifting things around to use empty space in chunks in the middle of the list. We'll only look at the tail chunk. The Deleteltem operation should look through each chunk array until the target element is found. Since the ChunkList can potentially have duplicates of the same elements, Deleteltem should just delete the first found instance of the element. If the chunk node is empty after removing the element, then the entire chunk should be removed from the link list. Do not use a dummy node because (a) it does not help the code much, and (b) dummy nodes are lame. Keep a single "size" variable for the whole list that stores the total number of client data elements stored in the list. Similarly, keep a separate size in each chunk to know how full it is.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Hi Buddy Because youre going to be able to create as a class and you didnt mention which language you want to use I am using the code to create the class of ChunkList Dont worry if you dont know what ...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