Question: Hello, this is for programming with java. We are dealing with linked lists this time. Below is the assignment. Please follow the directions. I have

Hello, this is for programming with java. We are dealing with linked lists this time. Below is the assignment. Please follow the directions. I have also added the Node constructor program for the Links program. Please use everything I have given you. Thank you for your help.  Hello, this is for programming with java. We are dealing with
//below is the Node constructor program needed for the link.java program.
//below is the linked list program that needs to be modified as specified by the assignment above.
////////////////////////////////////////////////////////////////
//Node.java constructor program
public class Node {
private Object item;
private Node next;
public Node(Object newItem) {
item = newItem;
next = null;
} // end constructor
public Node(Object newItem, Node nextNode) {
item = newItem;
next = nextNode;
} // end constructor
public void setItem(Object newItem) {
item = newItem;
} // end setItem
public Object getItem() {
return item;
} // end getItem
public void setNext(Node nextNode) {
next = nextNode;
} // end setNext
public Node getNext() {
return next;
} // end getNext
} // end class Node
///////////////////////
//Links.java program
public class Links
{
public static void main(String[] args)
{
Node pos1 = null;
Node pos2 = null;
pos1 = new Node(new Integer(13));
pos1.setNext(new Node(new Integer(15), null));
pos2 = new Node(new Integer(11), null);
pos2.setNext(pos1);
printList(pos2);
}
private static void printList(Node head)
{
if (head != null)
{
System.out.println(head.getItem());
printList(head.getNext());
}
}
}

Building and Tracing a Simple Linked List Take a look at the Links.java program in your attached handout. that would be created by the main method. Draw the linked list Now, compile and run the Links program and check to see if your list prints out in the manner that you would expect given a head pointer to the front of your list. Writing Simple Methods for Processing Linked Lists Add a recursive method named count to your Links program that can be used to count and return the number of nodes pointed to by a head pointer. Your method will have one parameter, the pointer head. Add an iterative method named findMax to your Links program that returns the largest value in a linked list pointed to by a head pointer. Your method will have one parameter, the pointer head. You should not be concerned about the data type of the elements stored in your nodes. Use the Comparable interface appropriately in your method Include method calls in main to test both of your new methods

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!