{"id":5941,"date":"2021-11-09T10:13:24","date_gmt":"2021-11-09T10:13:24","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=5941"},"modified":"2022-12-14T07:28:25","modified_gmt":"2022-12-14T07:28:25","slug":"convert-a-singly-linked-list-to-an-xor-linked-list","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/","title":{"rendered":"Convert A Singly Linked List to An XOR Linked List"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1657608471712-Article.jpg\" alt=\"\" \/><\/p>\n<p>In this article, we will see another problem of linked list Convert singly linked list into xor linked list. Linked list is a linear data structures. The node in linked list consists of two parts i.e. the data and the pointer of the next node. Let\u2019s see what exactly the XOR linked list is.<\/p>\n<h2>XOR Linked List<\/h2>\n<p>XOR linked list is the memory-efficient version of the doubly linked list, in which the next pointer of every node stores the XOR of the previous and next node\u2019s address. An XOR linked list uses only one address space per node to store the address of the previous and next node, while a  doubly linked list uses two address spaces per node to store the address of the previous and next list node (prev, next). <\/p>\n<p>To learn more about XOR linked list, please visit this article <a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/memory-efficient-doubly-linked-list\/\">Memory Efficient Doubly Linked List<\/a>.<\/p>\n<h2>How to convert singly linked list into xor linked list <\/h2>\n<p>In this problem, we are given a singly linked list and have to convert it to the XOR linked list.<\/p>\n<p>In this problem, we will be discussing how we can convert a singly linked list to XOR linked list. We will be provided with a singly linked list as the input, and our task will be to somehow convert this singly linked list to an XOR linked list.<\/p>\n<p><strong>Given singly linked list<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1657608488946-Image-01.png\" alt=\"\" \/><\/p>\n<p><strong>Converted XOR linked list<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1657608507841-Image-02.png\" alt=\"\" \/><\/p>\n<p><strong>An important XOR property:<\/strong><\/p>\n<ul>\n<li>If <strong>A XOR B = C<\/strong>, then <strong>A XOR C = B<\/strong>, as well as <strong>B XOR C = A<\/strong>.<\/li>\n<\/ul>\n<h2>Approach of Convert singly linked list into xor linked list<\/h2>\n<p>In an XOR linked list, each pointer stores the XOR of prev and next node address, so the approach is: <\/p>\n<ul>\n<li>First, we traverse the singly linked list and keep track of the previous node in a pointer. <\/li>\n<li>While we are traversing the list, we will change the next pointer of every node as <strong>curr.next = XOR(prev, next)<\/strong>.<\/li>\n<\/ul>\n<h2>Algorithm of Convert singly linked list into xor linked list<\/h2>\n<ol>\n<li>Create three nodes:\n<ul>\n<li>A <strong>current node<\/strong>, initially <strong>pointing to the head<\/strong>.<\/li>\n<li>A <strong>previous node<\/strong>, initially <strong>pointing to the null<\/strong>.<\/li>\n<li>A <strong>next node<\/strong>, initially <strong>pointing to the current.next<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<li>Iterate while <strong>current is not null<\/strong>:\n<ul>\n<li>Update <strong>next to current.next<\/strong>.<\/li>\n<li>Update <strong>current.next to XOR(prev, next)<\/strong>.<\/li>\n<li>Update <strong>previous to current<\/strong>.<\/li>\n<li>Update <strong>current to next<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong>printingXOR()<\/strong><\/p>\n<ul>\n<li>In the <strong>PrintingXOR function<\/strong>, we will start with a node previous, which will point to NULL, and a node current, which will point to the head. <\/li>\n<li>Now, we will print the current.data. <\/li>\n<li>For the traversal, we will now need the address of the next node. We can get that by calculating <strong>address(previous node) XOR address(current.next)<\/strong>. <\/li>\n<li>After getting the next node address, we will update our previous to current and current to the next node address. <\/li>\n<li>This process will go on till we reach the end of the list.<\/li>\n<\/ul>\n<h2>Algorithm of Convert singly linked list into xor linked list<\/h2>\n<ol>\n<li>Create a <strong>previous node<\/strong>, a <strong>current node<\/strong>, and a <strong>next node<\/strong>.<\/li>\n<li>Make <strong>previous point to NULL<\/strong> and <strong>current to the head<\/strong>.<\/li>\n<li>\n<p>Iterate while <strong>current<\/strong> is not null:<\/p>\n<ul>\n<li>Print current.data.<\/li>\n<li>Store the address of the next node as <strong>address(previous) XOR address(current.next)<\/strong>.<\/li>\n<li>Update the <strong>previous to current<\/strong> and the <strong>current to the next node address<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h2>Code Implementation of Convert singly linked list into xor linked list<\/h2>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_5942 {\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_5942 .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_5942 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_5942 .wpsm_nav-tabs > li.active > a, #tab_container_5942 .wpsm_nav-tabs > li.active > a:hover, #tab_container_5942 .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_5942 .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_5942 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_5942 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_5942 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_5942 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_5942 .wpsm_nav-tabs > li > a:hover , #tab_container_5942 .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_5942 .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_5942 .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_5942 .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_5942 .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_5942 .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_5942 .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_5942 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5942 .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_5942 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5942 .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_5942 .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_5942\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_5942\">\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_5942_1\" aria-controls=\"tabs_desc_5942_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_5942\">\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_5942_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\n\/\/ Linked list node\r\nclass Node {\r\n    int data;\r\n    Node next;\r\n\r\n    Node(int item) {\r\n        data = item;\r\n        next = null;\r\n    }\r\n}\r\n\r\npublic class PrepBytes {\r\n    static Node root;\r\n\r\n    \/\/ Printing singly linked list\r\n    static void printing(Node head) {\r\n        while (head != null) {\r\n            System.out.print(head.data + \" \");\r\n            head = head.next;\r\n        }\r\n        System.out.println();\r\n    }\r\n\r\n    static Node XOR(Node a, Node b) {\r\n        return b;\r\n    }\r\n\r\n    \/\/ This function will convert singly linked list\r\n    \/\/ to XOR linked list\r\n    static void convertToXOR(Node head) {\r\n        Node current = head;\r\n        Node prev = null;\r\n        Node next = current.next;\r\n\r\n        while (current != null) {\r\n\r\n            next = current.next;\r\n\r\n            current.next = XOR(prev, next);\r\n\r\n            prev = current;\r\n\r\n            current = next;\r\n        }\r\n    }\r\n\r\n    \/\/ This function will print the converted XOR linked list\r\n    static void printingXOR(Node head) {\r\n        Node curr = head;\r\n        Node prev = null;\r\n        Node next;\r\n        \r\n        while (curr != null) {\r\n\r\n            \/\/ print current node\r\n            System.out.print(curr.data + \" \");\r\n\r\n            next = XOR(prev, curr.next);\r\n            prev = curr;\r\n            curr = next;\r\n        }\r\n        System.out.println();\r\n    }\r\n\r\n    public static void main(String[] args) {\r\n\r\n        PrepBytes prep = new PrepBytes();\r\n        prep.root = new Node(53);\r\n        prep.root.next = new Node(69);\r\n        prep.root.next.next = new Node(96);\r\n        prep.root.next.next.next = new Node(27);\r\n        System.out.println(\"Singly Linked List Before Conversion: \");\r\n        printing(root);\r\n        convertToXOR(root);\r\n        System.out.println(\"After Conversion to XOR Linked List: \");\r\n        printingXOR(root);\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_5942 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_5942 a\"),jQuery(\"#tab-content_5942\"));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\nSingly Linked List Before Conversion:\n53 69 96 27\nAfter Conversion to XOR Linked List:\n53 69 96 27<\/code><\/pre>\n<p><strong>Time Complexity of Convert singly linked list into xor linked list<\/strong>: O(n), as we are only traversing the list.<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>So, in this article, we have tried to explain the most effective way to Convert singly linked list into xor linked list. This article taught us how to Convert singly linked list into xor linked list. Also, If you want to solve more questions on Linked List, which is curated by our expert mentors at <a href=\"https:\/\/www.prepbytes.com\/\">PrepBytes<\/a>, you can follow this link <a href=\"https:\/\/mycode.prepbytes.com\/interview-coding\/practice\/linked-list\">Linked List<\/a>.<\/p>\n<h2>FAQs related to Convert singly linked list into xor linked list<\/h2>\n<p><strong>1. How will you convert a singly linked list to a circular linked list?<\/strong><br \/>\nThe algorithm is quite simple: Traverse the linked list and find the last node. If the node is the last node and points to NULL, make it point to the head node. The singly linked list has now been converted into the circular linked list.<\/p>\n<p><strong>2. What does a XOR linked list have?<\/strong><br \/>\nThe memory efficient Doubly Linked List is called XOR Linked List or Memory Efficient as the list uses bitwise XOR operation to save space for one address. In the XOR linked list, instead of storing actual memory addresses, every node stores the XOR of addresses of previous and next nodes.<\/p>\n<p><strong>3. What is XOR used for?<\/strong><br \/>\n(eXclusive OR) A Boolean logic operation that is widely used in cryptography as well as in generating parity bits for error checking and fault tolerance. XOR compares two input bits and generates one output bit. The logic is simple. If the bits are the same, the result is 0.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will see another problem of linked list Convert singly linked list into xor linked list. Linked list is a linear data structures. The node in linked list consists of two parts i.e. the data and the pointer of the next node. Let\u2019s see what exactly the XOR linked list is. XOR [&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-5941","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 Singly Linked List to An XOR Linked List | Linked list articles | PrepBytes Blog<\/title>\n<meta name=\"description\" content=\"Learn the most effective way to convert a singly LinkedList to a XOR LinkedList.\" \/>\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-singly-linked-list-to-an-xor-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 Singly Linked List to An XOR Linked List | Linked list articles | PrepBytes Blog\" \/>\n<meta property=\"og:description\" content=\"Learn the most effective way to convert a singly LinkedList to a XOR LinkedList.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-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-11-09T10:13:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-12-14T07:28:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1657608471712-Article.jpg\" \/>\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\/convert-a-singly-linked-list-to-an-xor-linked-list\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/\"},\"author\":{\"name\":\"PrepBytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e\"},\"headline\":\"Convert A Singly Linked List to An XOR Linked List\",\"datePublished\":\"2021-11-09T10:13:24+00:00\",\"dateModified\":\"2022-12-14T07:28:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/\"},\"wordCount\":837,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1657608471712-Article.jpg\",\"articleSection\":[\"Linked list articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/\",\"name\":\"Convert A Singly Linked List to An XOR Linked List | Linked list articles | PrepBytes Blog\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1657608471712-Article.jpg\",\"datePublished\":\"2021-11-09T10:13:24+00:00\",\"dateModified\":\"2022-12-14T07:28:25+00:00\",\"description\":\"Learn the most effective way to convert a singly LinkedList to a XOR LinkedList.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1657608471712-Article.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1657608471712-Article.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-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 Singly Linked List to An XOR 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 Singly Linked List to An XOR Linked List | Linked list articles | PrepBytes Blog","description":"Learn the most effective way to convert a singly LinkedList to a XOR LinkedList.","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-singly-linked-list-to-an-xor-linked-list\/","og_locale":"en_US","og_type":"article","og_title":"Convert A Singly Linked List to An XOR Linked List | Linked list articles | PrepBytes Blog","og_description":"Learn the most effective way to convert a singly LinkedList to a XOR LinkedList.","og_url":"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2021-11-09T10:13:24+00:00","article_modified_time":"2022-12-14T07:28:25+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1657608471712-Article.jpg","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\/convert-a-singly-linked-list-to-an-xor-linked-list\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/"},"author":{"name":"PrepBytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e"},"headline":"Convert A Singly Linked List to An XOR Linked List","datePublished":"2021-11-09T10:13:24+00:00","dateModified":"2022-12-14T07:28:25+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/"},"wordCount":837,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1657608471712-Article.jpg","articleSection":["Linked list articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/","url":"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/","name":"Convert A Singly Linked List to An XOR Linked List | Linked list articles | PrepBytes Blog","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1657608471712-Article.jpg","datePublished":"2021-11-09T10:13:24+00:00","dateModified":"2022-12-14T07:28:25+00:00","description":"Learn the most effective way to convert a singly LinkedList to a XOR LinkedList.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-linked-list\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1657608471712-Article.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1657608471712-Article.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/convert-a-singly-linked-list-to-an-xor-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 Singly Linked List to An XOR 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\/5941","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=5941"}],"version-history":[{"count":4,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5941\/revisions"}],"predecessor-version":[{"id":10796,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5941\/revisions\/10796"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=5941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=5941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=5941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}