Home / Expert Answers / Computer Science / for-this-assignment-you-will-be-creating-a-linked-list-class-the-linked-list-class-will-be-based-on-pa740

(Solved): For this assignment you will be creating a linked list class. The linked list class will be based on ...



For this assignment you will be creating a linked list class. The linked list class will be based on the queue and node classes already created (a good option is to begin by copying the queue class into a new file and renaming it list or linked list).

The linked list class should have the following features:

  • All of the same data members (front, back, and possibly size) as the queue class.
  • All of the same member functions as the queue class: constructor(), append(), front(), pop(), find(), size(), destructor(). These shouldn't need to be modified significantly from the queue class. You will need to replace queue:: with linked:: (or whatever you name your class) in the function definitions.
  • A new function called print() that prints every item in the list.
  • A new function called reverserint() that prints every item in the list in reverse order. 
  • A new function called insert() that inserts a data element into a given location in the list. It takes two arguments: an int for the location in the array and a variable of entrytype for the data to be stored. It should create a new node using the data and walk down the list until it finds the correct location to store the item. If the list is too short (the item is supposed to be inserted at location 10, but the list only has 3 elements) it should insert the item at the end of the list and return an underflow error code. Otherwise it should return success error code.
  • A new function called remove() that removes a data element into a given location in the list. It takes one arguments: an int for the location in the array. It will need to walk down the list until it finds the correct location to remove the item. If the list is too short (the item is supposed to be removed from location 10, but the list only has 3 elements) it should return an underflow error code. Otherwise it should return success error code.
  • A new function called clear() that removes every element from the linked list. It should delete each element to avoid creating a memory leak. (One approach is to call the destructor, or to call pop() repeatedly until the list is empty.) This function does the same thing as the destructor, but allows the programmer to decide to clear the list and then reuse it.

Main:

You should write a main program that does the following:

  • Creates a linked list for storing integers.
  • use append() and a for loop to add all of the odd integers (inclusive) from 1 to 19 to the list.
  • pop() the first element from the list. 
  • insert() the number 8 at the 4th location in the list.
  • remove() the 7th item from the list.
  • append() the number 22 onto the list.
  • use find() twice to report whether the list contains the number 2 or the number 15.
  • print() the list.
  • reverseprint() the list.

Turn in:

  • The following:
    • A file with your node class
    • A file with your linked class
    • A file with your main program
    • A file showing your output

 



We have an Answer from Expert

View Expert Answer

Expert Answer


ANSWER: #include #include struct node { struct node *prev; struct node *next; int data; }; struct node *head; void insertion_beginning(); void insertion_last(); //void insertion_specified(); void deletion_beginning(); void deletion
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe