Description
Write a method that starts with a single linked list of doubles and a special value called the splitting value. The elements in the list are not in any particular order. The method should divide the nodes into two linked lists: one containing all the nodes that have an element less than the splitting value and another containing all the remaining nodes. If the original linked list contains any repeated doubles, meaning it has two or more nodes with the same element, the new linked list for that element should also have the same number of nodes that repeat this element. It does not matter whether you preserve the original linked list or destroy it in the presence of building the two new lists, but your comments should document what happens to the original linked list. The method should return two head references, one for each of the linked lists that were created. Use the LinkedList class to create your linked list. Also, use the following main method in your driver.
Use the Link and LinkList classes to create your linked list. Also, use the following main method in your driver:
public static void main(String[] args) {
LinkList theList = new LinkList(); // make list
Link firstHead = null;
Link secondHead = null;
theList.insertFirst(22, 2.99); // insert 4 items
theList.insertFirst(44, 4.99);
theList.insertFirst(66, 6.99);
theList.insertFirst(88, 8.99);
theList.displayList(); // display list
Link f = theList.find(4.99); // find item
if(f != null) {
Link arr[] = new Link[2];
arr = theList.split(44);
firstHead = arr[0];
secondHead = arr[1];
while(firstHead != null) // until end of list,
{
firstHead.displayLink(); // print data
firstHead = firstHead.next; // move to next link
}
System.out.println();
while(secondHead != null) // until end of list,
{
secondHead.displayLink(); // print data
secondHead = secondHead.next; // move to next link
}
}
else{
// your code
}
} // end main
} // end class
**To submit your Java files on Moodle:**
1. Create a folder with your last name.
2. Place Link.java, LinkList.java and your driver file into the folder.
3. Zip the folder.
4. Upload it into Moodle.