Question: ne common way to implement a list is a single-linked list containing a collection of nod 3 o es that refer to the data objects
ne common way to implement a list is a single-linked list containing a collection of nod 3 o es that refer to the data objects in the list. We can define the link nodes as follows: /.. One link in the list public class Link public Object value; // data value associated with this node public Link next; / next node in list or null if none /.* construct a new link with value v and next node n public Link(Object v, Link n) ( this.value v this.next n; A class using these links to implement a list would have an instance variable of type Link referring to the list data. A simple list implemented with a linked list public class SimpleLinkedList / private Link head; // first link in the list or null if II the list is empty Complete the definition of method addToEnd below of class SimpleLinkedList so it adds a new value to the end of the list. You may not assume there are any additional instance variables in class SimplelinkedList, and you may not add any. As for this problem, all you have to do is write a method that adds a node to the end of the linked list. /** Add value v to the end of this SimpleLinkedlist/ public void addToEnd(Object v)f
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
