Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Add comments where you can to explain. Thank you! 1) Implement an Interface List that contains all the methods mentioned below. The interface should use
Add comments where you can to explain. Thank you!
1) Implement an Interface List that contains all the methods mentioned below. The interface should use a generic type T that extends Comparable. Note that the java interface Comparable has a method: int compareTo(T o) that compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. Deliverable: List.java 2) Implement a SinglyLinkedList class that implements the interface List to store elements of a generic type: (i.e., public class SinglyLinkedList T extends Comparable T>> implements List D). 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 size0; 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 remove(int ); removes iem at position i of the list. 6a) public T min0; returns the item with the minimum value in the list; 6b) public T minR0; returns the item with the minimum value in the list (must be implemented as a recursive method 7a) public T max0; returns the item with the maximum value in the list; 7B) public T maxRO; returns the item with the maximum value in the list (must be implemented as a recursive method)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