Question: The SortedLinkedList class template) Complete the SortedLinkedList class template which is a doubly linked list and is implemented with a hcader node and a tail

 The SortedLinkedList class template) Complete the SortedLinkedList class template which is
a doubly linked list and is implemented with a hcader node and
a tail node. // SortedLinkedList.h // SortedLinkedList.h // A collection of data
are stored in the list by ascending order #ifndef SORTEDLIST H #de
fine SORTEDLIST H using namespace std template class SortedList private: // The

The SortedLinkedList class template) Complete the SortedLinkedList class template which is a doubly linked list and is implemented with a hcader node and a tail node. // SortedLinkedList.h // SortedLinkedList.h // A collection of data are stored in the list by ascending order #ifndef SORTEDLIST H #de fine SORTEDLIST H using namespace std template class SortedList private: // The basic single linked list node type // Nested inside of SortedList struct NodeType T data NodeType next NodeType* prev NodeType (const T& d) data-d; nextnullptr prevnullptr public: class const iterator public: Public constructor for const iterator const iterator) current nullptr: const T&operator const return retrieve cons t iterator & operatoE+ current current->next; return *this const iterator & operator-- current-cuzrent->prev return "this: friend class SortedList )i public: SortedListo init ) -SortedList) clear) delete head: delete tail: cout next const iterator begin) const return const iterator ( head-next // Return iterator representing endmarker of 1ist. // Mutator version is first, then accessor version iterator end return iterator( tail const iterator end const return const_iterator( tail ; // Return number of elements currently in the list. int size() const return thesize; // Return true if the list is empty, false otherwise bool empty const return size0 void clear while( empty iterator temp(erase (tail->prev)) private: int theSize: NodeType" head: NodeType* tail: void init thesize0 head = new NodeType (0); tail new NodeType (0) head->next = tail; tail->prev head: #endif 1) Read the code carefully, and understand the nested classes const iterator and iterator 2) Implement the member functions find, add_item, and remove item based on the corresponding comments. The three functions all return an iterator class. 3) Write an application program that e creates an int type sorted list using SortedLinkedList class template . prompt the user to enter int values, and add these values to the sorted list, stop adding the values when the user enter 0 . print the sorted list using iterator . prompt the user to enter int values to be removed, remove the values from the sorted list, stop removing the values when the user enter 0 . print the sorted list using iterator Three files should be submitted for this program question 1) the file SortedLinkedList.h which contains the implementation of SortedLinkedList class template, 2) the application file a2ql.cpp containing main) function, 3) a script file a2qlresult containing result. definition and Here are the sample runs Enter values in the sorted list: 3 6 2 951 8740 The sorted list is: 1 2 3 4 56 7 8 9 The values to be removed: 4 6 2 8 The sorted list is: 1 3 5 7 9

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!