Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Linked List Operations LinkedListType, unorderedLinkedList, and orderedLinkedList are given to yo... Linked List Operations LinkedListType, unorderedLinkedList, and orderedLinkedList are given to you in Chapter 17.

Linked List Operations LinkedListType, unorderedLinkedList, and orderedLinkedList are given to yo...

Linked List Operations

LinkedListType, unorderedLinkedList, and orderedLinkedList are given to you in Chapter 17. linkedListIterator is given to you as well. The files are supplied here.

Overload the insertFirst and insertLast pure virtual functions such that they accept a vector of possible values as parameters. All values in the vector are to be inserted.

Overload the deleteNode pure virtual function such that it accepts a vector of possible values. All values in the vector should be deleted.

Modify deleteNode such that an exception is thrown when called on an empty list and when the item to delete is not in the list.

Finally create a 2 lists using the STL list container. Add some values to them and sort them. Merge the two lists together into one list. Print the list using the screen iterator example from Appendix H.

Unorderelinklist code

template bool unorderedLinkedList:: unorderedLinkedList +search(const Type&) const: bool +insertFirst(const Type&): void +insertLast(const Type&): void +deleteNode(const Type&): void linkedListType unorderedLinkedList { search(const Type& searchItem) const nodeType *current; //pointer to traverse the list bool found = false; current = first; //set current to point to the first //node in the list while (current != nullptr && !found) //search the list if (current->info == searchItem) //searchItem is found found = true; else current = current->link; //make current point to //the next node return found; }//end search

Ordered Link List code

template bool orderedLinkedList:: { search(const Type& searchItem) const bool found = false; nodeType *current; //pointer to traverse the list current = first; //start the search at the first node while (current != nullptr && !found) if (current->info >= searchItem) found = true; else current = current->link; if (found) found = (current->info == searchItem); //test for equality return found; }//end search

Link List Type code

template class linkedListIterator { public: linkedListIterator(); //Default constructor //Postcondition: current = nullptr; linkedListIterator(nodeType *ptr); //Constructor with a parameter. //Postcondition: current = ptr; Type operator*(); //Function to overload the dereferencing operator *. //Postcondition: Returns the info contained in the node. linkedListIterator operator++(); //Overload the pre-increment operator. //Postcondition: The iterator is advanced to the next // node. bool operator==(const linkedListIterator& right) const; //Overload the equality operator. //Postcondition: Returns true if this iterator is equal to // the iterator specified by right, // otherwise it returns false. bool operator!=(const linkedListIterator& right) const; //Overload the not equal to operator. //Postcondition: Returns true if this iterator is not equal // to the iterator specified by right, // otherwise it returns false. private: nodeType *current; //pointer to point to the current //node in the linked list };

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Use a three-step process to develop effective business messages.

Answered: 1 week ago