Does anyone know how to fully set up a circular linked list, and its methods, remove, insert, and find?
Here is what i have so far but i have no idea if its proper
public class CLL
{
public class Node
{
int item;
Node next;
public Node()
{
this.item = 0;
this.next = null;
}
public Node(int e, Node n)
{
item = e;
next = n;
}
}
Node head;
public void insert(int item)
{
if(head == null)
{
head = new Node(item,null);
head.next = head;
}
else
{
head.next = new Node(item,head.next);
}
}
public void remove(int item)
{
}
public int find(int item)
{
}
}
First is my insert right? I think it is, but I keep feeling I may have missed something, and secondly, I have no idea how to do the remove function, or the find function If someone has code to help me it would be very awesome