Question: Write a class named CustomList.java that is a subclass of CMSC 2 5 6 LinkedList.java. The CustomList class must contain the following methods: / *
Write a class named CustomList.java that is a subclass of CMSCLinkedList.java. The CustomList class must contain the following methods:
Returns the middle element of the
If the number of elements in the list is even, there will be two middle nodes,
so return the second one.
For example, if the list contains the
method returns
If the list contains the
method returns
@throws IllegalStateException if the list is empty or null
@return an instance T
public T getMiddleElement
Returns the first half of the list.
If the number of elements in the list is odd, include the extra element.
For example if the list contains the
method returns a list
@return an instance of a class that implements the ListInterface
public ListInterface getFirstHalf
Returns the last half of the list.
If the number of elements in the list is odd, exclude the extra element.
For example if the list contains the
method returns a list containing
@return an instance of a class that implements the ListInterface
public ListInterface getLastHalf
Returns a List that consists of all and only the elements
in every fourth positions ie fourth, eighth, and so on in
the current string, in the same order as the current list.
If the list contains the
method returns
@return an instance of a class that implements the ListInterface
public ListInterface getEveryFourthElement
@return true if there are any elements in the list that occur twice
false otherwise
Note: if an element occurs more that twice, do not include it
If the list contains the
method returns true
public boolean hasDuplicates
@return an instance of a class that implements the ListInterface that
contains those elements in this list that appear more than once.
If the list contains the
method returns
public ListInterface getAllMultiples
Alters the list by deleting any elements that occur twice in the list.
Elements that occur more than times remain in the list.
If the list contains the
method removes and the list becomes
public void removeAllDuplicates
Removes the nth node from the end of the list
For example, if the list contains and is passed to the method
a value of is returned and the list becomes
@return the element from the position that was removed
public T removeNthNodeFromEndint n
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
