Question: 2) Implement a SinglyLinkedList class that implements the interface List to store elements of a generic type: (i.e., public class SinglyLinkedList > implements List). Just

2) Implement a SinglyLinkedList class that implements the interface List to store elements of a generic type: (i.e., public class SinglyLinkedList > implements List). Just as in the lectures, the class must have a nested static class called Node that stores the generic value and a reference variable next that points to the next node in the list. Here are the methods included in the interface: 1) public int size(); returns the size of the list (must be implemented as a recursive method).

2) public T get(int i); returns the element at position i (first position index is 0).

3) public int indexOf(Object item); returns the position of item ( note that it is of type objects).

4) public void add(int i, T item); adds item at position i of the list.

5) public T remove(int i); removes item at position i of the list.

6a) public T min(); returns the item with the minimum value in the list;

6b) public T minR(); returns the item with the minimum value in the list (must be implemented as a recursive method);

7a) public T max(); returns the item with the maximum value in the list;

7B) public T maxR(); returns the item with the maximum value in the list (must be implemented as a recursive method);

8) public boolean Empty(): returns true if the list is empty.

9) public void addAthead(T item) : adds an element at the head of the list

10) public void addAtEnd(T item): adds an element at the end of the list.

11) public void replace(T first, T second): takes two elements as an input, searches for the first(first) in the list, if it is found it will replace it with second ( without creating an nodes).

12) public List duplicate(T item): A recursive method to duplicate every element in a linked list, that is equal to a certain value. For example, if the linked list contains 4, 8, 4, 10 the element to duplicate is 4 the new list should contain 4,4,8,4,4, 10.

13) public void reverse(): A recursive method that prints out the data elements of a linked list in reverse order.

14) public List countGreaterThan(T threshold): A recursive method that returns a list containing all the elements in the original list that are larger than threshold.

15) public Boolean equals(Object other): A recursive method returns true if other is a list that has the same elements in the list with the same order.

16) public String toString(): returns a string representation of the elements in the list separated by a comm..

17) public List inorder(); returns a new list that has all the elements in the list sorted in an ascending order.

18) public void removeEven(): removes all the elements at even positions from the list (0,2, 4, ..) and keeps only the elements at the odd positions.

plz help solving part 3,9,10,11,13,15,17,18 if possible

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!