Question: Split a list into evens and odds. a . Derive the class intLinkedList from the class unorderedLinkedList as follows: class intLinkedList: public unorderedLinkedList { public:

Split a list into evens and odds. a. Derive the class intLinkedList from the class unorderedLinkedList as follows: class intLinkedList: public unorderedLinkedList { public: void splitEvensOddsList(intLinkedList &evensList, intLinkedList &oddsList); /* Function to rearrange the nodes of the linked list so * that evensList consists of even integers and oddsList * consists of odd integers. * Postcondition: evensList consists of even integers. * oddsList consists of odd integers. * The original list is empty. */ }; Also write the definition of the function splitEvensOddsList. Note that this function does not create any new nodes, it only rearranges the nodes of the original list so that nodes with even integers are in evensList and nodes with odd integers are in oddsList. b. Write a program that uses class intLinkedList to create a linked list of integers and then uses the function splitEvensOddsList to split the list into two sublists. The header files linkedList.h and unorderedLinkedList.h are supplied.

Your test program should produce output similar to this:

Enter integers ending with -999 34 62 21 10 15 90 66 53 7 120 88 36 90 11 17 24 10 -999 list: 34 62 21 10 15 90 66 53 7 120 88 36 90 11 17 24 10 evensList: 34 62 10 90 66 120 88 36 90 24 10 oddsList: 21 15 53 7 11 17

Your test program should use iterators to print the lists rather than the class print functions.

Turn in your all three of your template files, your test program, and screen shots of your testing.

After completing this assignment you will show that you can

Split a linked list without creating new nodes and without violating the class invariant.

Derive a non-template class from a template class.

Utilize an iterator to access a linked list.

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!