Problem

a. Add the following operation to the class orderedLinkedList:void mergeLists(orderedLinke...

a. 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.

b. Write the definition of the function template mergeLists to implement the operation mergeLists. Also write a program to test your function.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 5
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT