|
Create a class InsertableSLinkedList<T> that is a subclass of SLinkedList<T> which is contained in this zip file. InsertableSLinkedList.java should contain the following methods.
- A
getFirstNode() method that returns a reference to the first Node<T> object in the linked list.
- A
getNextNode() method that takes as a parameter a reference to a Node<T> object in the list and returns a reference to the next Node<T> object in the list (and returns null if the parameter node is the last node in the list).
- A
remove() method that takes as a parameter a reference to a Node<T> object in the list, removes that node from the list, and does not return a value.
- A
insertAfter() method that takes two parameters, a reference to a Node<T> object in the list and a reference to a Node<T> object not in the list, and inserts the second node into the list after the first node.
- A
insertBefore() method that takes two parameters, a reference to a Node<T> object in the list and a reference to a Node<T> object not in the list, and inserts the second node into the list before the first node.
In the zip file along with this file there is a program TestInsertableSLinkedList.java that tests your implementation of the InsertableSLinkedList<T> class. Do not make any changes to the TestInsertableSLinkedList.java file. When TestInsertableSLinkedList.java runs, it should produce output like that contained in the file SampleOutput.txt .
After you have the above methods working in InsertableSLinkedList.java , write a static (generic) method called sort that takes a single argument that is a reference to a InsertableSLinkedList object made up of nodes containing references to comparable objects. The sort method should do an insertion sort on the linked list using the methods defined above for the InsertableSLinkedList<T> class. In the zip file along with this file there is a program TestSort.java that tests your implementation of the sort() method. Do not make any changes to the TestSort.java file. When TestSort.java runs, it should produce output like that contained in the file TestSortOutput.txt .
Turn in a zip file called CS275Hw5Surname.zip containing your Java source file, InsertableSLinkedList.java , and also the original files contained in h5.zip . This assignment is due Wednesday, October 10.
|
|