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 defined in the textbook Section 2.5, add the following methods:

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!