Question: CPSC 2150 Lab 2 [30 Marks] Learning Outcomes Design and solve problem using linear data structures Practice on calculating the time complexity Identify and define
CPSC 2150\ Lab 2 [30 Marks]\ Learning Outcomes\ Design and solve problem using linear data structures\ Practice on calculating the time complexity\ Identify and define variables and methods with the least scopes\ Problem Description\ You have to implement and test a doubly linked list class. Save the header and implementation\ files separately.\ A. [5 Marks]:\ Begin by creating a template class NodeT that represents each node in the doubly linked list. This\ class should have:\ o public data members: item (template type attribute), next and prev (both pointers).\ o public methods: The class should have two constructors - one default that sets both the\ pointers to the nullptr and one with three parameters that sets the item, next and prev\ to the parameter values.\ B. [10 Marks]:\ Create a template class ListT that manages the doubly linked list. The class should support these\ operations:\ o Searching for a specific item in the list (bool searchItem(const T &item) const)\ o Inserting a node to the beginning (void insertBegin(const T &newEntry))\ o Deleting a specific node from the list. (T remove(const T &target))\ If deletion is not successful, throw the error\ throw std::runtime_error("The node can not be deleted");\ Otherwise return the data from the deleted node.\ o Define begin() which returns an iterator to the first element and end() which returns\ nullptr\ o ListIteratorT begin() const and ListIteratorT end() const\ The class should have the following private data members:\ o A pointer to a NodeT that represents the head (headPtr)\ o A pointer to a NodeT that represents the tail (tailPtr)\ o An int that records the current size of the list (i.e. the number of nodes in the list)\ itemCount\ The class should have the following public methods:\ o constructors, copy constructor, destructor and other methods to support the operations\ listed above.\ C. Iterator [5 Marks]:\ Create an iterator class ListIteratorT to traverse the doubly linked list. The iterator should provide\ methods like begin(), end(), operator++, operator!= and operator*\ Note: Check the lecture notes on Iterators for the signatures of these methods.\ D. [5 Marks]:\ Write a test program (TestList.cpp) that contains main function to demonstrate the functionality\ of the list. Perform sufficient operations like insertion, deletion, and searching to showcase the\ correctness of your implementation. Also, display the data in each of the n nodes of the list\ (traversing) using iterators.\ E. [5 Marks]:\ Follow good programming style (add comments, indentation, descriptive names, variables with\ least scope, less repetitive code).\ Hand In:\ Make a folder named Lab2_yourname containing all the files that you have created to answer\ this lab, zip the folder and submit the zipped file to BrightSpace by the due date and time.\ Note:\ Always follow good programming style.\ Refer to this http://geosoft.no/development/cppstyle.html
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
