Question
In the SingleLinkedList defined in the textbook Section 2.5, add the following methods: Write method indexOf. Write the remove method whose method heading follows. /**
In the SingleLinkedList
Write method indexOf.
Write the remove method whose method heading follows.
/** Remove the first occurrence of element item.
@param item The item to be removed
@return true if item is found and removed; otherwise, return false.
*/
public boolean remove(E item)
Write the following method add any helper methods.
/** Insert a new item before the one at position index, starting at 0
for the list head. The new item is inserted between the one at
position index1 and the one formerly at position index.
@param index The index where the new item is to be inserted
@param item The item to be inserted
@throws IndexOutOfBoundsException if the index is out of range
*/
public void add(int index, E item)
Write a main program to test and demonstrate the functions of the class.
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