logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

ChunkList is like a regular linked list, except each node contains a little fixed-size array of elements instead of just a single element.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

ChunkList

Original ChunkList concept by Nick Parlante. Adapted to an assignment by Varick Erickson.

1 INTRODUCTION

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 When the size of the list is 0, the head and tail pointers are null.

 

next

*

 

next

*

 

next

*

 

next

null

len

8

len

1

len

2

len

5

values

4

values

9

values

10

values

2

2

 

12

7

5

 

 

0

4

 

 

-1

2

 

 

2

8

 

 

 

0

 

 

 

1

 

 

 

 

  • Each chunk contains a fixed size ItemT [] 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

  • The empty collection should be implemented as null head and tail Only allocate chunks when actually needed.

  • ChunkList should implement the following methods:

  • Append(ItemT elem)

  • GetLength() → (refers to the total number of elements, not the number of chunk nodes)

  • GetIndex(int i) → (gets the item at index i)

  • Search(ItemT elem)

  • Print

  • Remove(ItemT elem) → (removes first instance of elem)

  • IsEmpty

  • The Append operation should add new elements at the end of the overall collection - i.e. new elements should 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

  • The Remove operation should look through each chunk array until the target element is Since the ChunkList can potentially have duplicates of the same elements, Remove 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

  • Keep a single "len" variable for the whole list that stores the total number of client data elements stored in the list. Similarly, keep a separate “len” variable in each chunk to know how full it

  • Search should return a copy of the element if found. Otherwise it should return

 

2 TEST DRIVER

 

You should have a test driver similar to the list driver demonstrated in class. Much of this driver can be reused for testing your implementation of ChunkList. In particular, it should support the following commands:

  • Append

  • GetLength

  • GetIndex

  • Search

  • Print

  • Remove

  • IsEmpty

 

IMPORTANT: Be sure to craft your input tests to ensure that your node removal works correctly.

 

3  QUESTIONS

  1. What is the advantage of the ChunkList approach as opposed to the Unsorted link list implementation given in Chapter 3?

  2. What would be the implications of increasing the size of ARRAY_SIZE to a very large value?

  3. What is the big O of:

    • Append

    • GetLength

    • GetIndex

    • Search

    • Print

    • Remove

    • IsEmpty

 

  1. Compare placing a new element into the FIRST available empty space versus placing a new element in the tail chunk. What are the advantages and disadvantages to automatically placing values at the tail node?

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

979 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

515 Answers

Hire Me
expert
Husnain SaeedComputer science

675 Answers

Hire Me
expert
Atharva PatilComputer science

673 Answers

Hire Me

Get Free Quote!

389 Experts Online