CSCI 261 - Programming Concepts - Summer 2022

Lab 5A - Double The Fun

This lab is due by Monday, June 13, 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


You are encouraged to use your singly-linked list as the starting point for this lab.


The Doubly-Linked List Class


We are going to now make a new class called DoublyLinkedList. This will necessitate creating a new struct for a DoublyNode to store the previous and next pointers.

The DoublyLinkedList class needs to have the following public methods created:

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

Lab Submission


Submit your DoublyNode.hpp, DoublyLinkedList.hpp, main.cpp file(s).

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


This lab is due by Monday, June 13, 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.