Question
iterator public java.util.Iterator iterator() This method must be implemented using an anonymous inner class that defines the iterator. Remember that we should be able to
iterator
public java.util.Iterator iterator()
This method must be implemented using an anonymous inner class that defines the iterator. Remember that we should be able to call the hasNext() method as many times as we want without changing what is considered the next element. You don't need to implement the iterator's remove() method, throw UnsupportedOperationException.
Specified by:
iterator in interface java.lang.Iterable
Returns:
iterator
getReverseList
public BasicLinkedList getReverseList()
Returns a new linkedlist with the elements of the current list in reverse order. You can assume sharing of data of each node is fine. This method must be implemented using recursion.(deep copy)
Returns:
linkedlist
getReverseArrayList
public java.util.ArrayList getReverseArrayList()
Returns an ArrayList with the element of the linked list in reverse order. This method must be implemented using recursion. (deep copy)
Returns:
ArrayList
===============================================
All three methods are in public class BasicLinkedList
This generic singly-linked list relies on a head (reference to first element of the list) and tail (reference to the last element of the list). Both are set to null when the list is empty. Both point to the same element when there is only one element in the list. A node structure has only two fields: data and next reference. The class must only define the following entities: a class Node, head and tail references and an integer representing the list size. All the entities are defined as protected so they can be accessed by the subclass.
Constructor Details
-
BasicLinkedList
public BasicLinkedList()
Defines an empty linked list. No nodes are created. We do not use dummy nodes for this list (if you don't know what a dummy list is don't worry about it).
-
Three methods please, you can write helper methods, upvote for exactly follow the instructions, thanks.
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