Given a Doubly circular linked list. The task is to find the position of an element in the list.
- Declare a temp pointer, and initialize it to head of the list.
- Iterate the loop until temp reaches start address (last node in the list, as it is in a circular fashion), check for the n element, whether present or not.
- If it is present, raise a flag, increment count and break the loop.
- At the last, as the last node is not visited yet check for the n element if present do step 3.
Below program illustrate the above approach:
Created circular doubly linked list is: 4 5 7 8 6 5 found at location 2
Time Complexity: As it uses linear search, so complexity is O(n).
- Search an element in a Doubly Linked List
- Doubly Circular Linked List | Set 1 (Introduction and Insertion)
- Doubly Circular Linked List | Set 2 (Deletion)
- Convert a given Binary Tree to Circular Doubly Linked List | Set 2
- Insertion at Specific Position in a Circular Doubly Linked List
- Convert an Array to a Circular Doubly Linked List
- Reverse a doubly circular linked list
- Remove all even parity nodes from a Doubly and Circular Singly Linked List
- Java Program to Search an Element in a Circular Linked List
- XOR Linked List - A Memory Efficient Doubly Linked List | Set 1
- XOR Linked List – A Memory Efficient Doubly Linked List | Set 2
- Difference between Singly linked list and Doubly linked list
- Circular Queue | Set 2 (Circular Linked List Implementation)
- Convert singly linked list into circular linked list
- Check if a linked list is Circular Linked List
- Sorted merge of two sorted doubly circular linked lists
- Construct a Doubly linked linked list from 2D Matrix
- Convert a Binary Tree to a Circular Doubly Link List
- Memory efficient doubly linked list
- Delete a node in a Doubly Linked List
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.