diff --git a/Tricky_Problems/CheckDoublyll.cpp b/Tricky_Problems/CheckDoublyll.cpp new file mode 100644 index 0000000..8043efa --- /dev/null +++ b/Tricky_Problems/CheckDoublyll.cpp @@ -0,0 +1,14 @@ +//Given a doubly linked list, the task is to check if it is circular or not. + +bool isCircular(Node * head) +{ + if(head==NULL) return false; + Node* temp=head; + Node* p=head->prev; + while(temp->next!=head && temp->next!=NULL) + { + temp=temp->next; + } + return temp->next==head && temp==p?true:false; + +} \ No newline at end of file