CSCI 261 - Programming Concepts - Maynooth 2022

Lab 4B - A Linked List Template

This lab is due by Friday, July 15, 2022, 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.


Instructions


This lab will generalize the Linked List created in Lab4A. Change your Node and LinkedList classes to be templated. Then add, or modify, the following methods:

Be sure to mark any methods that do not modify any data members as const appropriately.

To test your implementation, perform in main.cpp the following steps in order:

  1. Create a doubly linked list of integers
  2. Add the value 6 at pos 0
  3. Add the value 5 at pos 0
  4. Add the value 7 at pos 5
  5. Add the value 1 at pos -3
  6. Add the value 2 at pos 1
  7. Add the value 9 at pos 2
  8. Add the value 3 at pos 2
  9. Print the list forwards (prints 1 2 3 9 5 6 7)
  10. Set pos 3 to be 4
  11. Print the list forwards (prints 1 2 3 4 5 6 7)
  12. Remove pos -2
  13. Remove pos 0
  14. Remove pos 9
  15. Remove pos 5
  16. Remove pos 2
  17. Get and print pos 2 (prints 5)
  18. Print the size (prints 4)
  19. Print the list forwards (prints 2 3 5 6)
  20. Create a second list using the default constructor
  21. Print out the second list's size (should be zero)
  22. Assign the first list to the second list
  23. Print out both their sizes (should both be six)
  24. Add the following values to the original first list
    1. Add the value 1 at post 0
    2. Add the value 0 at post 0
  25. Print out both of their sizes (first should be eight, second should be six)
  26. Create a third list using the copy constructor and providing the original first list as the argument
  27. Print out all three sizes (first is eight, second six, third eight)
  28. Add the following values to the original first list
    1. Add the value 8 at post 10
    2. Add the value 9 at post 10
  29. Print out all three sizes (first is ten, second six, third eight)
  30. Delete all the lists to clean up the memory

Lab Submission


Submit your Node.hpp, LinkedList.hpp, main.cpp file(s).

You will submit your solution to this lab with the rest of Set4. Detailed instructions for doing this are posted in Assignment 4.


This lab is due by Friday, July 15, 2022, 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.