lab 34 exercise Mergelist

Assignment:

1.   The data file to be used in this lab is (file20.txt).

 2.   Building the initial linked list from (file20.txt) should follow this logic.  As each new piece of data (Id/Inv pair) comes off the data file, it is placed at the beginning of the list.  Therefore, the first values read from the data file will end up last in the list.  We do not want to have two external pointers (first/last) to the linked list as used in Lesson 33.  Instead, we want only one pointer to the first node in the list.

3.   The recursive merge sort algorithm will need the supporting algorithms of splitting and merging lists.

4.   The parameter list of the reverse function should be as follows:

       void reverseList (listPtr  &root);

      //  listPtr would be a typedef for something like listNode *

 

5.   Your program should consist of this sequence of scripted events:

      Load the data file and build the initial list

      Print the linked list - it is unordered

      Recursively merge sort the list

      Print the linked list - it is now sorted

      Reverse the linked list

      Print the linked list - it is now in descending order