Starting from:
$35

$29

HW14 Linked Lists Solution

    1. Create a doubly linked list with at least five nodes using a class template with template methods

        a. Print the linked list

    2. Add a copy constructor and overloaded assignment operator to the linked list

        a. Test the copy constructor and the copy assignment operator

    3. Read the linked list from part 1 and create another linked list reversing the logical order of the first linked list

        a. Print the linked list

    4. Delete the third node of each list. (Also try to (1) delete a non-existent node and (2) delete from an empty list)

        a. Print both linked lists

    5. Add a node in the middle of each linked list

        a. Print both linked lists

    6. Repeat steps 1-4 using doubles

    7. 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
HW14 - Linked Lists [100 pts]



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
HW14 - Linked Lists [100 pts]

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

...

Submit the tar package file hw14.tar to blackboard by Tuesday November 27, 2018.

More products