[SOLVED] Implement a MySingleLinkedList class in Java

25.00 $

Categories: ,
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon MySingleLinkedList.zip (0.6 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (2 votes)

The following Java implementation of a class Node is given:

private class Node<Object>

{

Node()

{

this(null, null);

}

Node(Object d)

{

this(d, null);

}

Node(Object d, Node n)

{

data = d; next = n;

}

Object data; Node next;

}

Assume that a singly linked list is implemented with a header node, but no tail node, and that it maintains only a reference to the header node.

Using the class Node described above, implement a MySingleLinkedList class in Java includes methods to:

 

(a)   int size() – return the size of the linked list.

(b)  void print() – print the linked list.

(c) boolean contains(Object x) – test if a value x is contained in the linked list.

(d) boolean add(Object x) – add a value x if it is not already contained in the linked list.

(e) boolean remove(Object x) – remove a value x if it is contained in the linked list.

Very important!

In the implementation of the MySingleLinkedList class resolution it is not allowed to use the interface Iterator.

  • MySingleLinkedList.zip