Applications of Circular doubly linked list

  • Managing song playlists in media player applications.
  • Managing shopping carts in online shopping.

This article is contributed by Akash Gupta.



Insertion in Doubly Circular Linked List

Circular Doubly Linked List has properties of both doubly linked list and circular linked list in which two consecutive elements are linked or connected by the previous and next pointer and the last node points to the first node by the next pointer and also the first node points to the last node by the previous pointer.

Following is the representation of a Circular doubly linked list node in C/C++: 

C++




static class node {
  int data;
 
  // pointer to next node
  node next;
 
  // pointer to prev node
  node prev;
}
  
// This code is contributed by Yash Agarwal(yashagarwal2852002)


C




// Structure of the node
struct node {
    int data;
 
    // Pointer to next node
    struct node* next;
 
    // Pointer to previous node
    struct node* prev;
};


Java




class Node {
    int data;
 
    // Pointer to the next node
    Node next;
 
    // Pointer to the previous node
    Node prev;
}


Python




class Node:
    def __init__(self):
        # Data in the node
        self.data = None
 
        # Pointer to the next node
        self.next = None
 
        # Pointer to the previous node
        self.prev = None


C#




public class Node {
    public int Data
    {
        get;
        set;
    }
    public Node Next
    {
        get;
        set;
    }
    public Node Prev
    {
        get;
        set;
    }
}
 
public class DoublyLinkedList {
    // The Doubly Linked List can be implemented here.
    // You can create instances of Node to build your list.
}


Javascript




class Node {
    constructor(data) {
        this.data = data;  // Data stored in the node
        this.next = null// Pointer to the next node
        this.prev = null// Pointer to the previous node
    }
}


 

Circular Doubly Linked LIst

Similar Reads

Insertion in Circular Doubly Linked List:

...

Advantages of circular doubly linked list:

...

Disadvantages of circular doubly linked list:

...

Applications of Circular doubly linked list:

...