Posts

Showing posts with the label Circular Double Linked List

Circular Double Linked List - All Operations

Image
  // The Double linked list node / circular double linked list node class Node{     int data;     Node next;     Node prev;     Node(int x){         this.data=x;         this.prev=null;         this.next=null;     } } public class Main {     // head and tail references of circular double linked list     Node head;     Node tail;       // function to add a node to the last of circular double linked list // Time Complexity - O(1) , Space Complexity - O(1)     public void addNode(int x){         // create a new node         Node newNode = new Node(x);               // if linked list is empty         if(head==null){             head=newNode;         ...