{"id":4117,"date":"2021-08-20T07:37:46","date_gmt":"2021-08-20T07:37:46","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=4117"},"modified":"2022-11-28T06:19:47","modified_gmt":"2022-11-28T06:19:47","slug":"check-if-a-linked-list-is-circular-linked-list","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/","title":{"rendered":"Check If A Linked List Is Circular Linked List"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185840215-linked%20list%20circular%20linked%20list-08-08.png\" alt=\"\" \/><\/p>\n<p>As we already saw many articles over the linked list. Let\u2019s have a look at another article on the linked list in which we have to check linked list is circular or not. A linked list is a linear data structure in which data is not stored continuously just like arrays.<\/p>\n<h2>How to check linked list is circular or not <\/h2>\n<p>Given a singly linked list, check if it is circular or not.<\/p>\n<h4>Examples<\/h4>\n<p><strong>Input:<\/strong> <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/input-1-8.png\" alt=\"\" \/><\/p>\n<p><strong>Output:<\/strong> NO<\/p>\n<p><strong>Input:<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/input-2-7.png\" alt=\"\" \/><\/p>\n<p><strong>Output:<\/strong> YES<\/p>\n<p><strong>Input:<\/strong>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/input-3-1.png\" alt=\"\" \/><\/p>\n<p><strong>Output:<\/strong> NO<\/p>\n<p>Before checking for a circular linked list, do you know what is a circular linked-list?<\/p>\n<p>A linked list is called circular if its last node points back to its first node.<\/p>\n<p>Now we will be able to understand the examples given above.<\/p>\n<ul>\n<li>For linked list <\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/input-1-8.png\" alt=\"\" \/><\/p>\n<p>Here the last node points to NULL, hence it is not a circular linked-list.<\/p>\n<ul>\n<li>For linked list <\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/input-2-7.png\" alt=\"\" \/><\/p>\n<p>Here the last node points back to the first node, hence it is a circular linked-list.<\/p>\n<ul>\n<li>For the linked list <\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/input-3-1.png\" alt=\"\" \/><\/p>\n<p>Here, the last node points don\u2019t point back to the first node. So, it is not a circular linked list.<\/p>\n<p>I hope you got the problem, now before moving to the approach section, try to think how will you approach it?<\/p>\n<h2>Approach 1 to check linked list is circular or not <\/h2>\n<p>One simple approach is to store the head of the linked list and now start traversing the linked list from next node of head and check if:<\/p>\n<ul>\n<li>We again reached the head, it means that the linked list is circular linked list.<\/li>\n<li>If we reached null, or we got stuck in a cycle that doesn\u2019t include head node, it means that the linked list is not a circular linked list.<\/li>\n<\/ul>\n<p>This approach is pretty simple, but here we will see how using cycle detection technique we find out if a linked list is circular or not in the next approach.<\/p>\n<h2>Approach 2 to check linked list is circular or not <\/h2>\n<p>I hope you got an idea of what a circular linked list is. <\/p>\n<p>Let\u2019s now look at how to identify such a linked list.<\/p>\n<p><strong>Helpful Observations<\/strong><\/p>\n<ul>\n<li>One thing we can observe is that only the linked lists containing a cycle can be a circular linked-list. So, if a linked list doesn\u2019t have any cycle, we know that it is not circular.<\/li>\n<li>Another observation is that circular linked-lists have a cycle, and the cycle starts at the first node itself.<\/li>\n<li>So, finally, a linked list with a cycle will be called a circular linked list only if the point at which the cycle starts is the first node.<\/li>\n<\/ul>\n<p>To identify a linked list as a circular linked list, we need to make the following checks:<\/p>\n<ul>\n<li>If the linked list contains a cycle or not.<\/li>\n<li>If it has a cycle, then whether the node at which the cycle starts is the head node or not.<\/li>\n<\/ul>\n<p>Let\u2019s state this in another way:<\/p>\n<ul>\n<li>A linked list is called circular if the next pointer of the last node of the list points back to the first node. If this pointer points to NULL or any other previous nodes (other than the first node), then the linked list won\u2019t be called circular.<\/li>\n<\/ul>\n<p>Since it is clear what we need to do, take some time and think about how to implement it.<\/p>\n<p>You must know how to detect a cycle in a linked list before proceeding further.<\/p>\n<p>Below is the algorithm explaining the steps we need to take to implement our idea.<\/p>\n<h2>Algorithm to check linked list is circular or not <\/h2>\n<ul>\n<li>Detect a cycle in the given linked list (we will use Floyd\u2019s cycle detection algorithm).<\/li>\n<li>If no cycle is found, then the linked list is linear. So return false.<\/li>\n<li>Else, if the cycle is found, find the starting point of the cycle.<\/li>\n<li>If the first node is the starting point, then the linked list is circular and return true.<\/li>\n<li>Else return false.<\/li>\n<\/ul>\n<h3>Dry Run to check linked list is circular or not <\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/Check-If-A-Linked-List-Is-Circular-Linked-List-1.png\" alt=\"\" \/><\/p>\n<h2>Code Implementation to check linked list is circular or not :<\/h2>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_4118 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_4118 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_4118 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_4118 .wpsm_nav-tabs > li.active > a, #tab_container_4118 .wpsm_nav-tabs > li.active > a:hover, #tab_container_4118 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_4118 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_4118 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_4118 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_4118 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_4118 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_4118 .wpsm_nav-tabs > li > a:hover , #tab_container_4118 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_4118 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_4118 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_4118 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_4118 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_4118 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_4118 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_4118 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_4118 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_4118 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_4118 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_4118 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_4118\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_4118\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_4118_1\" aria-controls=\"tabs_desc_4118_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_4118_2\" aria-controls=\"tabs_desc_4118_2\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C++<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_4118_3\" aria-controls=\"tabs_desc_4118_3\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Java<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_4118_4\" aria-controls=\"tabs_desc_4118_4\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Python<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_4118\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_4118_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"c\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include&lt;stdbool.h&gt;\r\n#include&lt;stdlib.h&gt;\r\n \r\nstruct Node {\r\n    int data;\r\n    struct Node* prev;\r\n    struct Node* next;\r\n};\r\n\r\nvoid push(struct Node** head_ref, int new_c)\r\n{\r\n    struct Node* new_node =\r\n            (struct Node*) malloc(sizeof(struct Node));\r\n    new_node-&gt;data = new_c;\r\n    new_node-&gt;prev = NULL;\r\n    new_node-&gt;next = (*head_ref);\r\n    if ((*head_ref) != NULL)\r\n        (*head_ref)-&gt;prev = new_node;\r\n     *head_ref = new_node;\r\n}\r\n\r\nbool isCircular(struct Node *head){\r\n struct Node *temp=head;\r\n while(temp!=NULL)\r\n { \/\/if temp points to head then it has completed a circle,thus a circular linked list.\r\n    if(temp-&gt;next==head)\r\n        return true;\r\n    temp=temp-&gt;next;\r\n}\r\n\r\nreturn false;\r\n\r\n}\r\nint main(void)\r\n{\r\n    struct Node* head = NULL;\r\n    push(&amp;head, 5);\r\n    push(&amp;head, 4);\r\n    push(&amp;head, 3);\r\n    push(&amp;head, 2);\r\n    push(&amp;head, 1);\r\n    \r\n    if(isCircular(head))\r\n\t\tprintf(&quot;Yes&#92;n&quot;);\r\n\telse\r\n\t\tprintf(&quot;No&#92;n&quot;);\r\n \r\n}\r\n\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_4118_2\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"cpp\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n\r\n#include&lt;bits stdc++.h=&quot;&quot;&gt;\r\nusing namespace std;\r\n\r\nstruct Node {\r\n    int val;\r\n    Node* next;\r\n\r\n    Node(int value){\r\n        val = value;\r\n        next = NULL;\r\n    }\r\n};\r\n\r\nvoid push_front(Node** head, int new_val){\r\n    Node* new_node = new Node(new_val);\r\n    new_node-&gt;next = *head;\r\n    *head = new_node;\r\n}\r\n\r\nbool isCircular(Node* head){\r\n    \/\/ detect cycle\r\n    Node *slow, *fast;\r\n    slow = fast = head;\r\n\r\n    while(fast!=NULL &amp;&amp; fast-&gt;next!=NULL){\r\n        slow = slow-&gt;next;\r\n        fast = (fast-&gt;next)-&gt;next;\r\n\r\n        if(slow==fast) break;\r\n    }\r\n\r\n    if(fast==NULL) return false;\r\n    if(fast-&gt;next == NULL) return false;\r\n\r\n\r\n    \/\/ now we have a loop\r\n    \/\/ find its starting point\r\n    slow = head;\r\n    while(slow!=fast){\r\n        slow = slow-&gt;next;\r\n        fast = fast-&gt;next;\r\n    }\r\n\r\n    \/\/ check if starting point of loop\r\n    \/\/ is the first node\r\n    if(slow == head) return true;\r\n    else return false;\r\n}\r\n\r\n\r\n\r\nint main(){\r\n    Node* h1 = NULL;\r\n\r\n    push_front(&amp;h1, 5);\r\n    push_front(&amp;h1, 4);\r\n    push_front(&amp;h1, 3);\r\n    push_front(&amp;h1, 2);\r\n    push_front(&amp;h1, 1);\r\n\r\n    \/\/ let's check if our lined list if circular or not\r\n    if(isCircular(h1)) cout&lt;&lt;&quot;YES&#92;n&quot;;\r\n    else cout&lt;&lt;&quot;NO&#92;n&quot;;\r\n\r\n    \/\/ make the next pointer of last node point to first node\r\n    Node* i = h1;\r\n    while(i-&gt;next!=NULL){\r\n        i = i-&gt;next;\r\n    }\r\n\r\n    i-&gt;next = h1;\r\n\r\n    \/\/ now the linked list is made circular\r\n    \/\/ 1-&gt;2-&gt;3-&gt;4-&gt;5\r\n    \/\/  &#92;----------\/\r\n\r\n    \/\/ let's check if our function finds out or not\r\n    if(isCircular(h1)) cout&lt;&lt;&quot;YES&#92;n&quot;;\r\n    else cout&lt;&lt;&quot;NO&#92;n&quot;;\r\n\r\n    \/\/ make the next pointer of last node point to second node\r\n    i-&gt;next = (h1-&gt;next);\r\n\r\n    \/\/ now the linked list isn't circular\r\n    \/\/ but has a loop\r\n    \/\/ 1-&gt;2-&gt;3-&gt;4-&gt;5\r\n    \/\/    &#92;--------\/\r\n\r\n    \/\/ let's check if our function finds out or not\r\n    if(isCircular(h1)) cout&lt;&lt;&quot;YES&#92;n&quot;;\r\n    else cout&lt;&lt;&quot;NO&#92;n&quot;;\r\n}\r\n\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_4118_3\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"java\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n\r\n \r\nclass Circular\r\n{\r\n    \r\nstatic class Node\r\n{\r\n    int data;\r\n    Node next;\r\n}\r\n \r\nstatic boolean isCircular( Node head)\r\n{\r\n   \r\n    if (head == null)\r\n    return true;\r\n \r\n    Node node = head.next;\r\n    while (node != null &amp;&amp; node != head)\r\n    node = node.next;\r\n\r\n    return (node == head);\r\n}\r\n \r\n\r\nstatic Node newNode(int data)\r\n{\r\n    Node temp = new Node();\r\n    temp.data = data;\r\n    temp.next = null;\r\n    return temp;\r\n}\r\npublic static void main(String args[])\r\n{\r\n    Node head = newNode(1);\r\n    head.next = newNode(2);\r\n    head.next.next = newNode(3);\r\n    head.next.next.next = newNode(4);\r\n \r\n    System.out.print(isCircular(head)? &quot;Yes&#92;n&quot; :&quot;No&#92;n&quot; );\r\n \r\n    head.next.next.next.next = head;\r\n \r\n    System.out.print(isCircular(head)? &quot;Yes&#92;n&quot; :&quot;No&#92;n&quot; );\r\n \r\n}\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_4118_4\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"Python\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"Python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n\r\n# Node structure of a doubly linked list node\r\nclass Node:\r\n\tdef __init__(self, data):\r\n\t\tself.data = data\r\n\t\tself.next = None\r\n\t\tself.prev = None\r\n\r\n# Using this function we will be inserting a new node in the list\r\ndef insert(head_ref, data):\r\n\t\r\n\tnew_node = Node(data)\r\n\tnew_node.data = data\r\n\tif (head_ref == None):\r\n\r\n\t\tnew_node.next = new_node\r\n\t\tnew_node.prev = new_node\r\n\r\n\telse :\r\n\t\t\r\n\t\tlast = head_ref.prev\r\n\t\tnew_node.next = head_ref\r\n\t\tnew_node.prev = last\r\n\t\tlast.next = new_node\r\n\t\thead_ref.prev = new_node\r\n\t\r\n\thead_ref = new_node\r\n\treturn head_ref\r\n\r\n# Using this function we will be merging two sorted doubly linked list\r\n# merge2SortedDLL stands for merge two sorted doubly linked list\r\ndef merge(first, second):\r\n\t\r\n\tif (first == None):\r\n\t\treturn second\r\n\r\n\tif (second == None):\r\n\t\treturn first\r\n\r\n\tif (first.data &lt; second.data) :\r\n\t\tfirst.next = merge(first.next,\r\n\t\t\t\t\t\tsecond)\r\n\t\tfirst.next.prev = first\r\n\t\tfirst.prev = None\r\n\t\treturn first\r\n\t\r\n\telse :\r\n\t\tsecond.next = merge(first,\r\n\t\t\t\t\t\t\tsecond.next)\r\n\t\tsecond.next.prev = second\r\n\t\tsecond.prev = None\r\n\t\treturn second\r\n\t\r\n# Using this function we will be merging two sorted doubly circular linked list\r\n# merge2SortedDCLL stands for merge two sorted doubly circular linked list\r\ndef merge2SortedDCLL(head1, head2):\r\n\t\r\n\tif (head1 == None):\r\n\t\treturn head2\r\n\r\n\tif (head2 == None):\r\n\t\treturn head1\r\n\r\n\tif (head1.prev.data &lt; head2.prev.data):\r\n\t\tlast_node = head2.prev\r\n\telse:\r\n\t\tlast_node = head1.prev\r\n\r\n\thead1.prev.next = None\r\n\thead2.prev.next = None\r\n\r\n\tfinalHead = merge(head1, head2)\r\n\r\n\tfinalHead.prev = last_node\r\n\tlast_node.next = finalHead\r\n\r\n\treturn finalHead\r\n\r\n# Using this function we will be printing the linked list content\r\ndef printList(head):\r\n\ttemp = head\r\n\r\n\twhile (temp.next != head):\r\n\t\tprint(temp.data, end = &quot; &quot;)\r\n\t\ttemp = temp.next\r\n\t\r\n\tprint(temp.data, end = &quot; &quot;)\r\n\r\nif __name__=='__main__':\r\n\thead1 = None\r\n\thead2 = None\r\n\r\n\thead1 = insert(head1, 7)\r\n\thead1 = insert(head1, 5)\r\n\thead1 = insert(head1, 3)\r\n\thead1 = insert(head1, 1)\r\n\r\n\tprint(&quot;Original linked list 1: &quot;, end = &quot;&quot;)\r\n\tprintList(head1)\r\n\tprint()\r\n\r\n\thead2 = insert(head2, 8)\r\n\thead2 = insert(head2, 6)\r\n\thead2 = insert(head2, 4)\r\n\thead2 = insert(head2, 2)\r\n\r\n\tprint(&quot;Original linked list 2: &quot;, end = &quot;&quot;)\r\n\tprintList(head2)\r\n\tprint()\r\n\tnewHead = merge2SortedDCLL(head1, head2)\r\n\r\n\tprint(&quot;Final Sorted List: &quot;, end = &quot;&quot;)\r\n\tprintList(newHead)\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_4118 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_4118 a\"),jQuery(\"#tab-content_4118\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<pre><code>Output\nNO\nYES\nNO<\/code><\/pre>\n<p><strong>Time complexity of check linked list is circular or not:<\/strong> O(n), where n is the number of nodes in the linked list.<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>Through this article, we learned how to check linked list is circular or not. Problems like these are good for strengthening your concepts in LinkedList. You can check our questions bank on Linked List, which is curated by our expert mentors at PrepBytes, you can follow this link <a href=\"https:\/\/mycode.prepbytes.com\/interview-coding\/practice\/linked-list\">Linked List<\/a>.<\/p>\n<h2>FAQs<\/h2>\n<p><strong>1. Can we access the random element of the LinkedList?<\/strong><br \/>\nWe can not access any element of the LinkedList directly. We don\u2019t have direct access to every element of LinkedList. If we want to access the ith element of the LinkedList, then we need to traverse the LinkedList till the ith index.<\/p>\n<p><strong>2. Can a linked list be circular?<\/strong><br \/>\nYes, the linked list can be a circular linked list if the last node is connected to the first node of the linked list and forms a circle.<\/p>\n<p><strong>3. What are the four types of linked lists?<\/strong><br \/>\nTypes of linked lists are:<\/p>\n<ul>\n<li>Singly linked list<\/li>\n<li>Doubly linked list<\/li>\n<li>Circular linked list<\/li>\n<li>Circular doubly linked list<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>As we already saw many articles over the linked list. Let\u2019s have a look at another article on the linked list in which we have to check linked list is circular or not. A linked list is a linear data structure in which data is not stored continuously just like arrays. How to check linked [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[125],"tags":[],"class_list":["post-4117","post","type-post","status-publish","format-standard","hentry","category-linked-list"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Check If A Linked List Is Circular Linked List | Linked List | Prepbytes<\/title>\n<meta name=\"description\" content=\"Learn to check whether a given linked list is circular or not. Through this article, we learned how to check if a linked list is circular or not.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Check If A Linked List Is Circular Linked List | Linked List | Prepbytes\" \/>\n<meta property=\"og:description\" content=\"Learn to check whether a given linked list is circular or not. Through this article, we learned how to check if a linked list is circular or not.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-20T07:37:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-28T06:19:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185840215-linked%20list%20circular%20linked%20list-08-08.png\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Check If A Linked List Is Circular Linked List\",\"datePublished\":\"2021-08-20T07:37:46+00:00\",\"dateModified\":\"2022-11-28T06:19:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/\"},\"wordCount\":876,\"commentCount\":1,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185840215-linked%20list%20circular%20linked%20list-08-08.png\",\"articleSection\":[\"Linked list articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/\",\"name\":\"How to Check If A Linked List Is Circular Linked List | Linked List | Prepbytes\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185840215-linked%20list%20circular%20linked%20list-08-08.png\",\"datePublished\":\"2021-08-20T07:37:46+00:00\",\"dateModified\":\"2022-11-28T06:19:47+00:00\",\"description\":\"Learn to check whether a given linked list is circular or not. Through this article, we learned how to check if a linked list is circular or not.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185840215-linked%20list%20circular%20linked%20list-08-08.png\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185840215-linked%20list%20circular%20linked%20list-08-08.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linked list articles\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/linked-list\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Check If A Linked List Is Circular Linked List\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Check If A Linked List Is Circular Linked List | Linked List | Prepbytes","description":"Learn to check whether a given linked list is circular or not. Through this article, we learned how to check if a linked list is circular or not.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/","og_locale":"en_US","og_type":"article","og_title":"How to Check If A Linked List Is Circular Linked List | Linked List | Prepbytes","og_description":"Learn to check whether a given linked list is circular or not. Through this article, we learned how to check if a linked list is circular or not.","og_url":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2021-08-20T07:37:46+00:00","article_modified_time":"2022-11-28T06:19:47+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185840215-linked%20list%20circular%20linked%20list-08-08.png","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Check If A Linked List Is Circular Linked List","datePublished":"2021-08-20T07:37:46+00:00","dateModified":"2022-11-28T06:19:47+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/"},"wordCount":876,"commentCount":1,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185840215-linked%20list%20circular%20linked%20list-08-08.png","articleSection":["Linked list articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/","url":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/","name":"How to Check If A Linked List Is Circular Linked List | Linked List | Prepbytes","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185840215-linked%20list%20circular%20linked%20list-08-08.png","datePublished":"2021-08-20T07:37:46+00:00","dateModified":"2022-11-28T06:19:47+00:00","description":"Learn to check whether a given linked list is circular or not. Through this article, we learned how to check if a linked list is circular or not.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185840215-linked%20list%20circular%20linked%20list-08-08.png","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185840215-linked%20list%20circular%20linked%20list-08-08.png"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/check-if-a-linked-list-is-circular-linked-list\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Linked list articles","item":"https:\/\/prepbytes.com\/blog\/category\/linked-list\/"},{"@type":"ListItem","position":3,"name":"Check If A Linked List Is Circular Linked List"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/4117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=4117"}],"version-history":[{"count":7,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/4117\/revisions"}],"predecessor-version":[{"id":10776,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/4117\/revisions\/10776"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=4117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=4117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=4117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}