CSCI 200 - Foundational Programming Concepts & Design - Fall 2022

Lab 4C - A Templated Linked List Class

This lab is due by Tuesday, November 01, 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 Lab4B. 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 9
  14. Remove pos 2
  15. Get and print pos 2 (prints 5)
  16. Print the size (prints 4)
  17. Print the list forwards (prints 2 3 5 6)
  18. Create a second list of integers using the default constructor
  19. Print out the second list's size (should be zero)
  20. Assign the first list to the second list
  21. Print out both their sizes (should both be four)
  22. Add the following values to the original first list
    1. Add the value 1 at pos 0
    2. Add the value 0 at pos 0
  23. Print out both of their sizes (first should be six, second should be four)
  24. Create a third list of integers using the copy constructor and providing the original first list as the argument
  25. Print out all three sizes (first is six, second four, third six)
  26. Add the following values to the original first list
    1. Add the value 8 at pos 10
    2. Add the value 9 at pos 10
  27. Print out all three sizes (first is eight, second four, third six)
  28. Delete all the lists to clean up the memory
  29. Create a list of strings
  30. Add the value "Hello" at pos 0
  31. Add the value "World" at pos 1
  32. Print the list forwards (prints Hello World)
  33. Delete the list of strings

Lab Submission


Submit your Node.hpp, LinkedList.hpp, main.cpp, Makefile 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 Tuesday, November 01, 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.