CS_1C Homework 14-doubly linked list Solved

35.00 $

Category:

Description

5/5 - (2 votes)
  1. Create a doubly linked list with at least five nodes using a class template with template methods
    1. Print the linked list
  2. Add a copy constructor and overloaded assignment operator to the linked list
    1. Test the copy constructor and the copy assignment

operator

  1. Read the linked list from part 1 and create another linked list reversing the logical order of the first linked list
    1. Print the linked list
  2. Delete the third node of each list. (Also try to (1) delete a non-existent node and (2) delete from an empty list)
    1. Print both linked lists
  3. Add a node in the middle of each linked list
    1. Print both linked lists
  4. Repeat steps 1-4 using doubles
  5. Run valgrind to test for memory leaks Sample printout (similar output for doubles):

Part 1:

Linked list 1:  88 78 62 143 60

Part 2:

Linked list 1 copy constructor:  88 78 62 143 60 Linked list 1 copy assignment:  88 78 62 143 60

Part 3:

Linked list 2:  60 143 62 78 88

Part 4 (after deleting the third node):

Linked list 1:  88 78 143 60

Linked list 2:  60 143 78 88

Part 5 (after adding a node in the middle of the list):

Linked list 1:  88 78 70 143 60

Linked list 2:  60 143 70 78 88

Part 6 – Repeat Part 1 thru 5 using doubles

Part 7 – Run valgrind memory leak check

Extra Credit [+10 pts]

Implement an ordered singly (or doubly) linked list class (suggested name listOrdered). This time linked nodes are stored internally in ascending order. Perform operations 1 thru 5 as outlined above using listOrdered.

Run valgrind to test for memory leaks.

Use the command script to capture your interaction compiling and running the program, including all operations, as shown below:

CS1C Fall 2018 TTH HW14 100pts Due: Tu 11/27/2018

cs1c@cs1c-VirtualBox ~/cs1c/hw/14 $ script hw14.scr Script started, file is hw14.scr cs1c@cs1c-VirtualBox ~/cs1c/hw/14 $ date

cs1c@cs1c-VirtualBox ~/cs1c/hw/14 $ ls -l

cs1c@cs1c-VirtualBox ~/cs1c/hw/14 $ make all

cs1c@cs1c-VirtualBox ~/cs1c/hw/14 $ ls -l

cs1c@cs1c-VirtualBox ~/cs1c/hw/14 $ ./hw14

… // print queue output after each addition, deletion operation above

… // print output from linked list steps 1 thru 5 above … // print output from valgrind memory leak check

cs1c@cs1c-VirtualBox ~/cs1c/hw/14 $ exit

Script done, file is hw14.scr

cs1c@cs1c-VirtualBox ~/cs1c/hw/14 $ make tar

  • Doubly_Linked_List-jus9jr.zip