Question: In this assignment, you are provided the code for a List class that has the functions to setup/initialize the list, insert to the list, delete

 In this assignment, you are provided the code for a List
class that has the functions to setup/initialize the list, insert to the
list, delete from the list and etc. Your task is to extend
the main function of the code to create an array of List

In this assignment, you are provided the code for a List class that has the functions to setup/initialize the list, insert to the list, delete from the list and etc. Your task is to extend the main function of the code to create an array of List objects and insert elements (randomly generated integers) to each of these List objects and print the contents of the List objects. The base address of the array of List objects is stored in a pointer named "listArray' of type List. The number of List objects (identified using the variable 'numLists') to be stored in the array is 5. The number of integer elements per List object (identified using the variable "listSize") is 10. Each List object is to be filled up with randomly generated integers in the range of 1... maxValue, where max Value = 50. Each insertion has to be made at index 0 of the List object. For example, if the random integers 23 45 12 34 49 are to be inserted to a List object, the contents of the List object after each insertion (at index 0) looks like this: 23 45 23 12 45 23 34 12 45 23 49 34 12 45 23 After filling up all the List objects, print the contents of each of them. After printing the contents of all the List objects, delete each List object and eventually clear up the space for the array of List objects. Submission: 1 - 75 pts) The entire.cpp file with the main function implemented as indicated. 2) A PDF document containing the following: (a - 20 pts) With the insertions occurring at index 0 of a List, determine the time complexity of inserting 'n' elements to every List object in an array of 'm' List objects. Show the pseudo code for the insertion step and analyze the time complexity. (6 - 5 pts) A screenshot of the execution of your code. #include #include #include #include #include using namespace std; class List private: int array: int maxSize; int endofArray: public: List()) List(int size) { maxSize = size; array - new int [maxSize); endofArray = -1; void setup(int size) { maxSize - size: array = new int[maxSize); endofArray --1; bool isEmpty04 if (endofArray == -1) return true; return false; > void resize(int s) { int temprray = array: array = new int[s]; for (int index = 0; index endofArray+1 || insert Index for (int index = endofArray; index >= insert Index; index--> array[index+1) = array[index]; array[insert Index] - data; endofArray++; } void deleteList() { delete[] array: > void PrintListot for (int index = 0; index > numLists; int listSize; int main() { using namespace std::chrono; srand(time(NULL)); int numLists; cout > numLists; int listSize; cout > listSize; int maxValue; cout > maxValue; // Create an array of numLists, each of size list Size // Setup/Initialize the member variables of each of the List objects in the array // Populate each List object of the array with values ranging from 1 to maxValue // Every time an integer is to be inserted to a List object, the integer is inserted // at index 0 of the List object. // Print the contents of each List object // Delete all the List objects and clear the space allocated for the array of List // objects system("pause"); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!