{"id":5944,"date":"2022-07-13T06:41:36","date_gmt":"2022-07-13T06:41:36","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=5944"},"modified":"2022-12-14T10:43:15","modified_gmt":"2022-12-14T10:43:15","slug":"convert-a-given-binary-tree-to-circular-doubly-linked-list","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/","title":{"rendered":"Convert a given Binary Tree To Circular Doubly Linked List"},"content":{"rendered":"<p>![](https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645007594981-Article_164.png)<\/p>\n<p>In this article, we will deep dive and discuss how to convert the binary tree to circular doubly linked list. Converting a binary tree to circular doubly linked list will enhance your data structures topic like binary tree and linked list. Let\u2019s discuss our topic \u201cbinary tree to circular doubly linked list\u201d.<\/p>\n<p>## How To Convert Binary Tree To Circular Doubly Linked List<br \/>\nIn this problem, we are given a ternary tree, and we have to convert it to a doubly linked list.<\/p>\n<p>Let\u2019s try to understand the problem statement with the help of examples.<\/p>\n<p>**Note:**A ternary tree is very much similar to a binary tree, but instead of having two children, it has three children left, middle, and right.<\/p>\n<p>Let\u2019s assume that the given ternary tree is:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_1-22.png\" alt=\"\" \/><\/p>\n<p> \t&#8211; According to the problem statement, we need to convert this given ternary tree to a doubly linked list.<br \/>\n \t&#8211; After converting the given tree to doubly linked list, our doubly linked list will look like:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_2-23.png\" alt=\"\" \/><\/p>\n<p>Taking another example, if the given ternary tree is:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_3-13.png\" alt=\"\" \/><\/p>\n<p> \t&#8211; Then, in this case, after conversion, our doubly linked list will be:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_4-9.png\" alt=\"\" \/><\/p>\n<p>Now, I think from the above examples, the problem statement is clear. Let\u2019s see how we can approach it.<\/p>\n<p>Before moving to the approach section, try to think about how you can approach this problem.<\/p>\n<p> \t&#8211; If stuck, no problem, we will thoroughly see how we can approach this problem in the next section.<\/p>\n<p>Before moving on further, let\u2019s see some helpful observations, which will help us to approach this problem.<\/p>\n<p>**Helpful Observations To Convert Binary Tree To Circular Doubly Linked List**<br \/>\nLet\u2019s compare the relative position of nodes in the binary tree and doubly linked list.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_5-5.png\" alt=\"\" \/><\/p>\n<p> &#8211; Node 15 is the root node, so it occurs first in the doubly linked list. It is not part of any subtree rooted at some other node, i.e., it is not a child of any other node.<br \/>\n &#8211; In the resultant doubly linked list, node 4 will occur before nodes 9, 5, and 1 as they are children&#8217;s of node 4.<br \/>\n &#8211; Similarly, node 6 will occur before nodes 2, 7, and 10 as they are the children&#8217;s of node 6.<\/p>\n<p>Hence, it is clear from above observations that every node should be inserted first in the doubly linked list, followed by its children&#8217;s.<\/p>\n<p> &#8211; If we consider the children&#8217;s of node 4, we observe that node 9 is before node 5 and node 5 is before node 1 in the doubly linked list.<br \/>\n &#8211; If we consider the children&#8217;s of node 6, we observe that node 2 is before node 7 and node 7 is before node 10 in the doubly linked list.<\/p>\n<p>Hence, it is clear from above observations that from children&#8217;s, the left child will be inserted first, followed by the mid-child and at last the right child.<\/p>\n<p>In this way, our doubly linked list will be formed.<\/p>\n<p>## Approach To Convert Binary Tree To Circular Doubly Linked List<br \/>\nWhile creating a Doubly Linked List from a ternary tree, the Doubly Linked List must follow the following properties:<\/p>\n<p> &#8211; The <strong>left pointer<\/strong> of a node in ternary tree will act a <strong>prev<\/strong> pointer in the Doubly Linked List.<br \/>\n &#8211; The <strong>right pointer<\/strong> of a node in ternary tree will act a <strong>next<\/strong> pointer in the Doubly Linked List.<br \/>\n &#8211; The <strong>middle pointer<\/strong> of a ternary tree node will point to null.<\/p>\n<p>To create a desired Doubly Linked List from the given Ternary tree:<\/p>\n<p> &#8211; We need to traverse the given tree using preorder traversal and insert the nodes in our Doubly Linked List following the preorder traversal of the tree.<\/p>\n<p>In <strong>preorder traversal<\/strong>, the root is visited first, followed by its left child and then right child. So, we will add the node in our doubly linked list as soon as it is visited while doing preorder traversal on the given ternary tree.<\/p>\n<p>## Algorithm To Convert Binary Tree To Circular Doubly Linked List<\/p>\n<p> &#8211; Create <strong>head<\/strong> and <strong>tail<\/strong> of the linked list (<strong>head<\/strong> will be the starting point of the Doubly Linked List, and <strong>tail<\/strong> will store the last node of the Doubly Linked List).<br \/>\n &#8211; Perform a preorder traversal on the given tree.<br \/>\n &#8211; If the node is not present already in our linked list, then insert the node at the tail of the linked list. To insert a node to the list, we will use tail pointer. Suppose we have to add a node to the list, then:<\/p>\n<p> &#8211; First, the <strong>tail.right<\/strong> will point to <strong>node<\/strong> to be inserted <strong>(tail.right = node)<\/strong>.<br \/>\n &#8211; Then <strong>node.left<\/strong> will point to <strong>tail<\/strong> <strong>(node.left = tail)<\/strong>.<\/p>\n<p> &#8211; Finally, output the desired Doubly Linked List.<\/p>\n<p>### Dry Run To Convert Binary Tree To Circular Doubly Linked List<br \/>\n<img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_6-5.png\" alt=\"\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_7-5.png\" alt=\"\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_8-6.png\" alt=\"\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_9-2.png\" alt=\"\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_10-1.png\" alt=\"\" \/><\/p>\n<p>## Code Implementation To Convert Binary Tree To Circular Doubly Linked List<br \/>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_5318 {\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_5318 .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_5318 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_5318 .wpsm_nav-tabs > li.active > a, #tab_container_5318 .wpsm_nav-tabs > li.active > a:hover, #tab_container_5318 .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_5318 .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_5318 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_5318 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_5318 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_5318 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_5318 .wpsm_nav-tabs > li > a:hover , #tab_container_5318 .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_5318 .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_5318 .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_5318 .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_5318 .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_5318 .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_5318 .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_5318 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5318 .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_5318 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5318 .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_5318 .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_5318\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_5318\">\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_5318_1\" aria-controls=\"tabs_desc_5318_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>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\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_5318\">\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_5318_1\">\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\npublic class Prepbytes {\r\n    static class treeNode {\r\n         int data;\r\n         treeNode left, middle, right;\r\n\r\n         public treeNode(int data) {\r\n             this.data = data;\r\n             left = middle = right = null;\r\n         }\r\n     }\r\n     static treeNode tail;\r\n\r\n     public static void push(treeNode node) {\r\n         tail.right = node;\r\n\r\n         node.left = tail;\r\n\r\n         node.middle = node.right = null;\r\n         tail = node;\r\n     }\r\n\r\n     \/* This is a recursive method to perform preorder traversal on the ternary tree. *\/\r\n     public static void preorderRec(treeNode node, treeNode head) {\r\n         if (node == null)\r\n             return;\r\n         treeNode left = node.left;\r\n         treeNode middle = node.middle;\r\n         treeNode right = node.right;\r\n         if (tail != node) {\r\n             push(node);\r\n         }\r\n         preorderRec(left, head);\r\n         preorderRec(middle, head);\r\n         preorderRec(right, head);\r\n     }\r\n\r\n     \/* This method is used to start the preorder traversal on the ternary tree. *\/\r\n     public static treeNode startPreorderTraversal(treeNode root) {\r\n         treeNode head = root;\r\n         tail = root;\r\n         preorderRec(root, head);\r\n         return head;\r\n     }\r\n\r\n     \/* This method is used to print the final doubly linked list once all the nodes from the ternary tree have been added to it. *\/\r\n     public static void printList(treeNode head) {\r\n         while (head != null) {\r\n             if (head.right != null) {\r\n                 System.out.print(head.data + \" \");\r\n             } else {\r\n                 System.out.print(head.data);\r\n             }\r\n             head = head.right;\r\n         }\r\n\r\n     }\r\n\r\n     public static void main(String args[]) {\r\n         treeNode root = new treeNode(15);\r\n         root.left = new treeNode(4);\r\n         root.middle = new treeNode(6);\r\n         root.right = new treeNode(8);\r\n         root.left.left = new treeNode(9);\r\n         root.left.middle = new treeNode(5);\r\n         root.left.right = new treeNode(1);\r\n         root.middle.left = new treeNode(2);\r\n         root.middle.middle = new treeNode(7);\r\n         root.middle.right = new treeNode(10);\r\n         treeNode head = startPreorderTraversal(root);\r\n         System.out.println(\"Converted Doubly linked list\");\r\n         printList(head);\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\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_5318 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_5318 a\"),jQuery(\"#tab-content_5318\"));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<\/p>\n<p>Output<br \/>\nConverted Doubly linked list<br \/>\n15 4 9 5 1 6 2 7 10 8<\/p>\n<p>**Time Complexity To Convert Binary Tree To Circular Doubly Linked List:** O(n), where n is the total number of nodes in the given tree. We are traversing the tree which takes linear time.<\/p>\n<p>In this blog, we have discussed the best approach to convert binary tree to circular doubly linked list. If you want to conquer the data structures then you have to practice questions of data structures like linked list regularly. Our experts have planned and made the list of questions of linked list, you can checkout <a href=\"https:\/\/mycode.prepbytes.com\/interview-coding\/practice\/linked-list\">Prepbytes (Linked List)<\/a> for solving more questions of linked list.<\/p>\n<p>## FAQ<\/p>\n<p>**1. How do you convert a binary tree to a doubly linked list?**<br \/>\nThe binary tree is a tree data structure in which each node has at most two children nodes. This can be achieved by traversing the tree in the in-order manner, that is, left the child -&gt; root -&gt;right node. Traverse left subtree and convert it into the doubly linked list by adding nodes to the end of the list<\/p>\n<p>**2. What is a circular doubly linked list?**<br \/>\nA Doubly Circular Linked List is a data structure that has properties of both Circular Linked List and Doubly Linked List. It is a list in which the last node of the list points to the start node, creating a loop.<\/p>\n<p>**3. Which companies asked the conversion of binary trees into circular doubly linked lists?**<br \/>\nAmazon, Adobe, JP Morgan, Morgan Stanley, BNY Mellon in their recent interviews asked for the conversion of binary trees into circular doubly linked lists.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>![](https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645007594981-Article_164.png) In this article, we will deep dive and discuss how to convert the binary tree to circular doubly linked list. Converting a binary tree to circular doubly linked list will enhance your data structures topic like binary tree and linked list. Let\u2019s discuss our topic \u201cbinary tree to circular doubly linked list\u201d. ## How [&hellip;]<\/p>\n","protected":false},"author":3,"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-5944","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>Convert a given Binary Tree To Circular Doubly Linked List<\/title>\n<meta name=\"description\" content=\"Learn the most effective way to convert a Binary Tree to Circular Doubly Linked List. Get the detailed explanations for C, C++ and python interview questions.\" \/>\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\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Convert a given Binary Tree To Circular Doubly Linked List\" \/>\n<meta property=\"og:description\" content=\"Learn the most effective way to convert a Binary Tree to Circular Doubly Linked List. Get the detailed explanations for C, C++ and python interview questions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-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=\"2022-07-13T06:41:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-12-14T10:43:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_1-22.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=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/\"},\"author\":{\"name\":\"PrepBytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e\"},\"headline\":\"Convert a given Binary Tree To Circular Doubly Linked List\",\"datePublished\":\"2022-07-13T06:41:36+00:00\",\"dateModified\":\"2022-12-14T10:43:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/\"},\"wordCount\":1080,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_1-22.png\",\"articleSection\":[\"Linked list articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/\",\"name\":\"Convert a given Binary Tree To Circular Doubly Linked List\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_1-22.png\",\"datePublished\":\"2022-07-13T06:41:36+00:00\",\"dateModified\":\"2022-12-14T10:43:15+00:00\",\"description\":\"Learn the most effective way to convert a Binary Tree to Circular Doubly Linked List. Get the detailed explanations for C, C++ and python interview questions.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#primaryimage\",\"url\":\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_1-22.png\",\"contentUrl\":\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_1-22.png\",\"width\":595,\"height\":300},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-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\":\"Convert a given Binary Tree To Circular Doubly 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\/39fcf072e04987f16796546f2ca83c2e\",\"name\":\"PrepBytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g\",\"caption\":\"PrepBytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/prepbytes\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Convert a given Binary Tree To Circular Doubly Linked List","description":"Learn the most effective way to convert a Binary Tree to Circular Doubly Linked List. Get the detailed explanations for C, C++ and python interview questions.","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\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/","og_locale":"en_US","og_type":"article","og_title":"Convert a given Binary Tree To Circular Doubly Linked List","og_description":"Learn the most effective way to convert a Binary Tree to Circular Doubly Linked List. Get the detailed explanations for C, C++ and python interview questions.","og_url":"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2022-07-13T06:41:36+00:00","article_modified_time":"2022-12-14T10:43:15+00:00","og_image":[{"url":"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_1-22.png","type":"","width":"","height":""}],"author":"PrepBytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"PrepBytes","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/"},"author":{"name":"PrepBytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e"},"headline":"Convert a given Binary Tree To Circular Doubly Linked List","datePublished":"2022-07-13T06:41:36+00:00","dateModified":"2022-12-14T10:43:15+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/"},"wordCount":1080,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_1-22.png","articleSection":["Linked list articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/","url":"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/","name":"Convert a given Binary Tree To Circular Doubly Linked List","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_1-22.png","datePublished":"2022-07-13T06:41:36+00:00","dateModified":"2022-12-14T10:43:15+00:00","description":"Learn the most effective way to convert a Binary Tree to Circular Doubly Linked List. Get the detailed explanations for C, C++ and python interview questions.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-linked-list\/#primaryimage","url":"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_1-22.png","contentUrl":"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_1-22.png","width":595,"height":300},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/convert-a-given-binary-tree-to-circular-doubly-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":"Convert a given Binary Tree To Circular Doubly 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\/39fcf072e04987f16796546f2ca83c2e","name":"PrepBytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g","caption":"PrepBytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/prepbytes\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5944","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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=5944"}],"version-history":[{"count":8,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5944\/revisions"}],"predecessor-version":[{"id":10840,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5944\/revisions\/10840"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=5944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=5944"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=5944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}