Explore BrainMass

Java MyLinkedList with insertSortNoDuplicate method

Write a Java class MyLinkedList that includes implementation of:

i. int insertSortNoDuplicate(Object object) that will insert an object at correct position in the ascending (increasing) order. The method also will return -1 if the given object already exists in the current list, otherwise returns 0.

ii. Iterator getIterator(int order) that will return an Iterator object reference that will traverse the elements on the current based on the value of order. If the order is 0 then will traverse from head to tail, otherwise it will traverse from tail to head.

iii. void updateList(MyLinkedList otherlist) that will update the current list with a given otherlist. If an element in current list exists in the otherlist then replace (update) it, otherwise insert (add) it using the above insertSortNoDuplicate method.

Solution Preview

See the attached file.
This response works with following type of linked list node.

private class Node
public Student value;

Attached archive contains three files:,, and .

After unzipping the archive, go to folder ...

Solution Summary

Java version "1.7.0_21" was used during development of this program.