Explore BrainMass

Java MyLinkedList with insertSortNoDuplicate method

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

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.

© BrainMass Inc. brainmass.com October 25, 2018, 9:02 am ad1c9bdddf

Solution Preview

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

private class Node
public Student value;

Attached archive 562134.zip contains three files: MyLinkedList.java, Student.java, and TestMyLinkedList.java .

After unzipping the archive, go to folder ...

Solution Summary

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