And Please send me the written answer pls. Page 1 of 6 Circular Linked List Assi
ID: 3586376 • Letter: A
Question
AndPlease send me the written answer pls. Page 1 of 6 Circular Linked List Assignment Overview A circular linked list is essentially a singly linked list in which the next pointer of the tail node is set to point to the head node of the linked list rather than set to nul. The first figure below shows a linked list as a singly linked list. The second figure below shows the singly linked list from the first figure as a circular linked list. In this assignment, you will write code for an implementation of a circular linked list 12 Head Tail Singly Linked List 12 Tail Circular Linked List
Explanation / Answer
import.java.util.Iterator;
public interface List<ArrayType>
{
void clear();
int size();
boolean isEmpty();
AnyType get(int index);
AnyType set(int index, AnyType newValue);
boolean add(AnyType newValue);
void add(int index, AnyType newValue);
AnyType remove(int index);
Iterator<AnyType> iterator();
}
******** and circular linked list.java is *******************
import java.util.Iterator;
import java.util.ConcurrentModificationException;
import java.util.NoSuchElementException;
public class CircularLinkedList<AnyType> implements List<AnyType>
{
private stati class Node<AnyType>
private AnyType data;
private Node<AnyType> next;
public Node(AnyType d, Node<AnyType> n)
{
setData(d);
setNext(n);
}
public AnyType getData()
{
return
public void setData(AnyType d)
{
data=d;
}
public Node<AnyType> getNext()
{
return next;
}
public void setNext(Node<AnyType> n)
{
next=n;
}
}
private int theSize;
private int modCount;
private Node<AnyType> tail
public CircularLinkedList()
{
}
public void clear()
{
}
public int size()
{
}
public boolean isEmpty()
{
}
public AnyType get(int index)
{
}
public AnyType set(int index,AnyType newValue)
{
}
public AnyType remove(int index)
{
}
public void rotate()
{
}
public Iterator<AnyType> iterator()
{
return new LinkedListIterator();
}
private Node<AnyType> getNode(int index)
{
return (getNode(index,0,size()-1));
}
private Node<AnyType> getNode(int index, int lower, int upper)
{
}
private class LinkedListIterator implements Iterator<AnyType>
{
private Node<AnyType> previous;
private Node<AnyType> current;
private int expectedModCount;
private boolean okToRemove;
LinkedListIteraor()
{
}
public boolean hasNext()
{
}
public AnyType next()
{
}
public void remove()
{
}
}
}