Search an Element in Doubly Circular Linked 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).
My Personal Notes arrow_drop_up