Given an array of N elements. The task is to write a program to convert the array into a circular doubly linked list.
The idea is to start traversing the array and for every array element create a new list node and assign the prev and next pointers of this node accordingly.
- Create a pointer start to point to the starting of the list which will initially point to NULL(Empty list).
- For the first element of the array, create a new node and put that node’s prev and next pointers to point to start to maintain the circular fashion of the list.
- For the rest of the array elements, insert those elements to the end of the created circular doubly linked list.
Below is the implementation of above idea:
The list is: 1 2 3 4 5
- Convert a given Binary Tree to Circular Doubly Linked List | Set 2
- Convert a Binary Tree to a Circular Doubly Link List
- Reverse a doubly circular linked list
- Doubly Circular Linked List | Set 2 (Deletion)
- Search an Element in Doubly Circular Linked List
- Doubly Circular Linked List | Set 1 (Introduction and Insertion)
- Insertion at Specific Position in a Circular Doubly Linked List
- Convert singly linked list into circular linked list
- Convert a given Binary Tree to Doubly Linked List | Set 2
- Convert a given Binary Tree to Doubly Linked List | Set 3
- Convert a given Binary Tree to Doubly Linked List | Set 1
- Convert a given Binary Tree to Doubly Linked List | Set 4
- Convert a Binary Tree into Doubly Linked List in spiral fashion
- Replace even nodes of a doubly linked list with the elements of array
- Circular Queue | Set 2 (Circular Linked List Implementation)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.