Question: Implement a singly-linked list in Java , add four methods of it: (1) boolean add (int e): appends the specified node to the end of
Implement a singly-linked list in Java, add four methods of it: (1) boolean add (int e): appends the specified node to the end of this list if e is not present in the list; returns true if a node is added to this list, false otherwise.
(2) boolean remove (int e): removes the first occurrence of the specified element from this list, if it is present; returns true if a node is removed from this list, false otherwise.
(3) int size(): returns the number of elements in this list.
(4) boolean equals(Object obj): returns true if the input object represents the same linked list, false otherwise.
Write test cases to test your implementation of the singly-linked list and its methods
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
