The linked list should be of type java.util.LinkedList
.
The data file to be used in this lab is (file20.txt).
Build the initial linked list from (file20.txt) following this logic:
place each new Id/Inv pair that is read from the data file at the beginning of the list
Therefore, the first values read from the data file will end up last in the list.
The recursive merge sort algorithm will need the supporting algorithms of splitting and merging lists. List iterators should be used to implement these methods.
Your program should consist of the following 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
If your teacher so chooses, you will be provided with a program shell consisting of a MergeList
class containing a main method, and the Item
class. All of the code development will be in the MergeList
class.