Linked List in Java
A linked list is a linear data structure. Linked List is collection of nodes; nodes are containers having at least two parts: one for storing data and another for storing address of another node. Linked List is very flexible kind of data structure; insertion and deletion of any node from any position is possible, but random access of the nodes is not possible in the linked list.
The elements in a linked list are linked using pointers as shown in the below image:
fig:
Linked List
Types:
- ·      Â
SinglyÂ
Linked List
- ·      Â
Doubly Linked List
- ·      Â
Circular Linked List
- ·      Â
Doubly Circular Linked List
Singly Linked List:
Creation
of Singly Linked List node in java:
Class SLLNode{
         int info;
         SLLNode next;
}
Doubly
Linked List:
A doubly linked list or a two-way linked list is a more complex type of linked list which contains a pointer to the next as well as the previous node in sequence, Therefore, it contains three parts are data, a pointer to the next node, and a pointer to the previous node. This would enable us to traverse the list in the backward direction as well.
Creation
of Doubly Linked List node in java:
Class DLLNode{
         int info;
         DLLNode next,prev;
}
Circular
Linked List:
A circular linked list
is that in which the last node contains the pointer to the first node of the
list. While traversing a circular liked list, we can begin at any node and
traverse the list in any direction forward and backward until we reach the same
node we started. Thus, a circular linked list has no beginning and no end.
Creation
of Circular Linked List node in java:
Class CLLNode{
         int info;
         CLLNode next;
}
Doubly
Circular Linked List:
A Doubly Circular
linked list or a circular two-way linked list is a more complex type of
linked-list that contains a pointer to the next as well as the previous node in
the sequence. The difference between the doubly linked and circular doubly list
is the same as that between a singly linked list and a circular linked list.
The circular doubly linked list does not contain null in the previous field of
the first node.Â
Creation
of Doubly Circular Linked List node in java:
Class DCLLNode{
         int info;
         DCLLNode next,prev;
}