From 7ea32ae02c0195b26094bba35ade7d3bfe3be278 Mon Sep 17 00:00:00 2001 From: Manasi Wader Date: Wed, 16 Sep 2020 17:11:54 +0530 Subject: [PATCH] check if it is doubly linked list --- Tricky_Problems/CheckDoublyll.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Tricky_Problems/CheckDoublyll.cpp 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