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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started