- Create a doubly linked list with at least five nodes using a class template with template methods
- Print the linked list
- Add a copy constructor and overloaded assignment operator to the linked list
- Test the copy constructor and the copy assignment
operator
- Read the linked list from part 1 and create another linked list reversing the logical order of the first linked list
- Print the linked list
- Delete the third node of each list. (Also try to (1) delete a non-existent node and (2) delete from an empty list)
- Print both linked lists
- Add a node in the middle of each linked list
- Print both linked lists
- Repeat steps 1-4 using doubles
- 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
[email protected] ~/cs1c/hw/14 $ script hw14.scr Script started, file is hw14.scr [email protected] ~/cs1c/hw/14 $ date
[email protected] ~/cs1c/hw/14 $ ls -l
[email protected] ~/cs1c/hw/14 $ make all
[email protected] ~/cs1c/hw/14 $ ls -l
[email protected] ~/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
[email protected] ~/cs1c/hw/14 $ exit
Script done, file is hw14.scr
[email protected] ~/cs1c/hw/14 $ make tar
Reviews
There are no reviews yet.