Merge Linked Lists Add the following operation to the class orderedLinkedList: v
ID: 3528754 • Letter: M
Question
Merge Linked Lists Add the following operation to the class orderedLinkedList: void mergeLists (orderedLinkedList &list1, orderedLinkedList &list2); // This function creates a new list by merging the // elements of list1 and list2. // Postcondition: first points to the merged list; list1 and list2 are empty Example: Consider the following statements: orderedLinkedList newList; orderedLinkedList list1; orderedLinkedList list2; Suppose list1 points to the list with the elements 2 6 7 and list2 points to the list with the elements 3 5 8. The statement: newList.mergeLists(list1, list2); Creates a new linked list with the elements in the order 2 3 5 6 7 8 and the object newList points to this list. Also, after the preceding statement executes, list1 and list2 are empty. Write the definition of the function template mergeLists to implement the operation mergeLists. Also write a program to test your function.Explanation / Answer
#include #include "linkedListType.h" using namespace std; template class orderedLinkedList: public linkedListType{ public: bool search(const Type& searchItem) const; //func to determine whether searchItem is in the list //postcondition: returns true if searchitem is in the list, otherwise false void insert(const Type& newItem); //func to insert newItem into list //postcondition: first points to the new list, newItem is inserted at the proper place //in the list, and count is incremented by 1 void insertFirst(const Type& newItem); //func to insert newItem at the beginning of the list //postcondition: first points to the new list, newitem is inserted at the beginning of the list, last points to the last //node in the list, and count is incremented by 1 void insertLast(const Type& newItem); //func to insert newItem at the end of the list //postcondition: first points to the new list, newitem is inserted at the end of the list, last points to the last //node in the list, and count is incremented by 1 void deleteNode(const Type& deleteItem); //func to delete deleteItem from the list //postcondition: if found, the node containing deleteItem is deleted from the list, first points to the first node // of the new list, count is decremented by 1. If deleteItem is not in the list, a message is printed. protected: int count; //valiable to store the number of list elements nodeType *first; //pointer to the first node of the list nodeType *last; //pointer to the last node of the list }; ................plsz rate me 1st.............