VOOZH about

URL: https://www.geeksforgeeks.org/dsa/search-an-element-in-doubly-circular-linked-list/

⇱ Search an Element in Doubly Circular Linked List - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Search an Element in Doubly Circular Linked List

Last Updated : 11 Jul, 2025

Pre-requisite: Convert an Array to a Circular Doubly Linked List, Doubly Circular Linked List
Given a doubly circular linked list. The task is to find the position of an element in the list.

Image Representation

👁 Search Image

Algorithm:  

  • Declare a temp pointer, and initialize it to the head of the list.
  • Iterate the loop until temp reaches the start address (last node in the list, as it is in a circular fashion), and 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 does step 3.

The below program illustrates the above approach:  


Output: 
Created circular doubly linked list is: 4 5 7 8 6 
5 found at location 2

 

Time Complexity: O(n), as we are using a loop to traverse n times. Where n is the number of nodes in the linked list.

Auxiliary Space: O(1), as we are not using any extra space.

Comment