{"id":3639,"date":"2021-08-06T11:39:24","date_gmt":"2021-08-06T11:39:24","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=3639"},"modified":"2022-03-08T12:18:01","modified_gmt":"2022-03-08T12:18:01","slug":"recursively-reversing-a-linked-list-a-simple-implementation","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/","title":{"rendered":"Recursively reversing a Linked List &#8211; A simple implementation"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925754905-102.Recursively%20Reversing%20A%20Linked%20List_Artboard%203.png\" alt=\"\" \/><\/p>\n<h3>Introduction<\/h3>\n<p>The linked list is one of the most important concepts and data structures to learn while preparing for interviews. Having a good grasp of Linked Lists can be a huge plus point in a coding interview.<\/p>\n<\/p>\n<h3>Problem Statement<\/h3>\n<p>In this question, we are given a singly linked list. We have to reverse the linked list, using recursion.<\/p>\n<h3>Problem Statement Understanding<\/h3>\n<p>Let the given linked list be 1 -&gt; 2 -&gt; 3 -&gt; 4. Now, with the help of recursion, we have to reverse the linked list. The reverse linked list is 4 -&gt; 3 -&gt; 2 -&gt; 1.<\/p>\n<p><strong>Input:<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/50_2-01.png\" alt=\"\" \/><\/p>\n<p><strong>Output:<\/strong> <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/50_1-01.png\" alt=\"\" \/><\/p>\n<p><strong>Explanation:<\/strong> The given linked list has been reversed.<\/p>\n<p>This question is not a very complex one. We just have to reverse the given linked list. The only requirement is to use recursion. <\/p>\n<p>We should not think that recursion is tough. We will be doing almost the same operations that we would\u2019ve done with a loop. The only addition will be that we will keep recurring until we hit the base case. Let us have a glance at the approach.<\/p>\n<h3>Approach<\/h3>\n<p>The approach is going to be pretty simple. We are going to traverse through the list and make the previous node of the current node as its next node. After this, we are going to recur for the next node. <\/p>\n<p>When we reach the last node, we will make it the head of our new linked list, and then recursively the other nodes will get added to our new linked list one by one.<\/p>\n<h3>Algorithm<\/h3>\n<ul>\n<li>Base Case &#8211; If the node is NULL, return NULL.<\/li>\n<li>Another Base Case &#8211; If node &#8211; &gt; next is NULL, we will make the node the head of the new linked list, as it is the last node of the list.<\/li>\n<li>If the base cases fail, proceed further.<\/li>\n<li>Create a new node node1 and store the recurred value of node -&gt; next in it.<\/li>\n<li>Now, as the recursive calls return values, make node1 -&gt; next point to the current node.<\/li>\n<li>Make current node &#8211; &gt; next point to NULL<\/li>\n<li>By doing the above steps, we are changing the links of every node, i.e. we are making the current node point to its previous node.<\/li>\n<li>In the end, return current node. <\/li>\n<\/ul>\n<h3>Dry Run<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/50_3-01.png\" alt=\"\" \/><\/p>\n<h4>Code Implementation<\/h4>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_3641 {\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_3641 .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_3641 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_3641 .wpsm_nav-tabs > li.active > a, #tab_container_3641 .wpsm_nav-tabs > li.active > a:hover, #tab_container_3641 .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_3641 .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_3641 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_3641 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_3641 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_3641 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_3641 .wpsm_nav-tabs > li > a:hover , #tab_container_3641 .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_3641 .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_3641 .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_3641 .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_3641 .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_3641 .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_3641 .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_3641 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_3641 .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_3641 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_3641 .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_3641 .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_3641\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_3641\">\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_3641_1\" aria-controls=\"tabs_desc_3641_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_3641_2\" aria-controls=\"tabs_desc_3641_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_3641_3\" aria-controls=\"tabs_desc_3641_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_3641_4\" aria-controls=\"tabs_desc_3641_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_3641\">\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_3641_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;stdlib.h&gt;\r\n \r\n\/\/ A Linked List Node\r\nstruct Node\r\n{\r\n    int data;\r\n    struct Node* next;\r\n};\r\n \r\n\/\/ Helper function to print a given linked list\r\nvoid printList(struct Node* head)\r\n{\r\n    struct Node* ptr = head;\r\n    while (ptr)\r\n    {\r\n        printf(&quot;%d &mdash;&gt; &quot;, ptr-&gt;data);\r\n        ptr = ptr-&gt;next;\r\n    }\r\n \r\n    printf(&quot;NULL&#92;n&quot;);\r\n}\r\n \r\n\/\/ Helper function to insert a new node at the beginning of the linked list\r\nvoid push(struct Node** head, int data)\r\n{\r\n    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));\r\n    newNode-&gt;data = data;\r\n    newNode-&gt;next = *head;\r\n \r\n    *head = newNode;\r\n}\r\n \r\n\/\/ Recursive function to reverse a given linked list. It reverses the\r\n\/\/ given linked list by fixing the head pointer and then `.next`\r\n\/\/ pointers of every node in reverse order\r\nvoid recursiveReverse(struct Node* head, struct Node** headRef)\r\n{\r\n    struct Node* first;\r\n    struct Node* rest;\r\n \r\n    \/\/ empty list base case\r\n    if (head == NULL) {\r\n        return;\r\n    }\r\n \r\n    first = head;           \/\/ suppose first = {1, 2, 3}\r\n    rest = first-&gt;next;     \/\/ rest = {2, 3}\r\n \r\n    \/\/ base case: the list has only one node\r\n    if (rest == NULL)\r\n    {\r\n        \/\/ fix the head pointer here\r\n        *headRef = first;\r\n        return;\r\n    }\r\n \r\n    \/\/ recursively reverse the smaller {2, 3} case\r\n    \/\/ after: rest = {3, 2}\r\n    recursiveReverse(rest, headRef);\r\n \r\n    \/\/ put the first item at the end of the list\r\n    rest-&gt;next = first;\r\n    first-&gt;next = NULL;     \/\/ (tricky step &mdash; make a drawing)\r\n}\r\n \r\n\/\/ Reverse a given linked list. The function takes a pointer\r\n\/\/ (reference) to the head pointer\r\nvoid reverse(struct Node** head) {\r\n    recursiveReverse(*head, head);\r\n}\r\nint main()\r\n{\r\n    struct Node* head = NULL;\r\n \r\n    \/\/ create linked list 10-&gt;12-&gt;8-&gt;4-&gt;6\r\n    push(&amp;head, 16);\r\n    push(&amp;head, 14);\r\n    push(&amp;head, 80);\r\n    push(&amp;head, 12);\r\n    push(&amp;head, 20);\r\n    reverse(&amp;head);\r\n    printList(head);\r\n \r\n    return 0;\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_3641_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#include &lt;iostream&gt;\r\nusing namespace std;\r\n\r\nstruct Node {\r\n    int data;\r\n    struct Node* next;\r\n    Node(int data)\r\n    {\r\n        this-&gt;data = data;\r\n        next = NULL;\r\n    }\r\n};\r\n  \r\nstruct LinkedList {\r\n    Node* head;\r\n    LinkedList()\r\n    {\r\n        head = NULL;\r\n    }\r\n  \r\n    \/\/ Function to reverse the list\r\n    Node* reverse(Node* node)\r\n    {\r\n        if (node == NULL)\r\n            return NULL;\r\n\r\n        \/\/ if current node is the last node\r\n        if (node-&gt;next == NULL) {\r\n            head = node;\r\n            return node;\r\n        }\r\n        \/\/ recur for the next node\r\n        Node* node1 = reverse(node-&gt;next);\r\n\r\n        \/\/ Change the links accordingly\r\n        node1-&gt;next = node;\r\n        node-&gt;next = NULL;\r\n        return node;\r\n    }\r\n\r\n    void print()\r\n    {\r\n        struct Node* temp = head;\r\n        while (temp != NULL) {\r\n            cout &lt;&lt; temp-&gt;data &lt;&lt; &quot; &quot;;\r\n            temp = temp-&gt;next;\r\n        }\r\n    }\r\n  \r\n    void push(int data)\r\n    {\r\n        Node* temp = new Node(data);\r\n        temp-&gt;next = head;\r\n        head = temp;\r\n    }\r\n};\r\n  \r\nint main()\r\n{\r\n    LinkedList ll;\r\n    ll.push(4);\r\n    ll.push(3);\r\n    ll.push(2);\r\n    ll.push(1);\r\n    cout &lt;&lt; &quot;Given linked list&#92;n&quot;;\r\n    ll.print();\r\n    ll.reverse(ll.head);\r\n    cout &lt;&lt; &quot;&#92;nReversed Linked list &#92;n&quot;;\r\n    ll.print();\r\n    return 0;\r\n}\r\n\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\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_3641_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\nimport java.io.BufferedWriter;\r\nimport java.io.IOException;\r\nimport java.io.OutputStreamWriter;\r\nimport java.util.Scanner;\r\n\r\npublic class ReverseLinkedListRecursive {\r\n    \r\n\r\n    static class Node {\r\n        public int data;\r\n        public Node next;\r\n\r\n        public Node(int nodeData) {\r\n            this.data = nodeData;\r\n            this.next = null;\r\n        }\r\n    }\r\n\r\n    static class LinkedList {\r\n        public Node head;\r\n\r\n        public LinkedList() {\r\n            this.head = null;\r\n        }\r\n\r\n        public void insertNode(int nodeData) {\r\n            Node node = new Node(nodeData);\r\n\r\n            if (this.head != null) {\r\n                node.next = head;\r\n            }\r\n            this.head = node;\r\n        }\r\n    }\r\n\r\n\r\n    public static void printSinglyLinkedList(Node node,\r\n                        String sep) throws IOException {\r\n        while (node != null) {\r\n            System.out.print(String.valueOf(node.data) + sep);\r\n            node = node.next;\r\n        }\r\n    }\r\n\r\n\r\n    static Node reverse(Node head) {\r\n        if(head == null) {\r\n            return head;\r\n        }\r\n\r\n\r\n        if(head.next == null) {\r\n            return head;\r\n        }\r\n\r\n        Node newHeadNode = reverse(head.next);\r\n\r\n\r\n        head.next.next = head;\r\n        head.next = null;\r\n\r\n        return newHeadNode;\r\n    }\r\n\r\n    private static final Scanner scanner = new Scanner(System.in);\r\n\r\n    public static void main(String[] args) throws IOException {\r\n            LinkedList llist = new LinkedList();\r\n            llist.insertNode(4);\r\n            llist.insertNode(3);\r\n            llist.insertNode(2);\r\n            llist.insertNode(1);\r\n            System.out.println(&quot;Given linked list:&quot;);\r\n            printSinglyLinkedList(llist.head, &quot; &quot;);\r\n            System.out.println();\r\n            System.out.println(&quot;Reversed Linked list:&quot;);\r\n            Node llist1 = reverse(llist.head);\r\n            printSinglyLinkedList(llist1, &quot; &quot;);\r\n\r\n        scanner.close();\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_3641_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\nclass Node:\r\n    def __init__(self, data):\r\n        self.data = data\r\n        self.next = None\r\n    \r\ndef LinkedList():\r\n    head = None\r\n        \r\ndef reverse(node):\r\n    if (node == None):\r\n        return node\r\n        \r\n    if (node.next == None):\r\n        return node\r\n        \r\n    node1 = reverse(node.next)\r\n    node.next.next = node\r\n    node.next = None\r\n    return node1\r\n\r\ndef printList():\r\n    temp = head\r\n    while (temp != None) :\r\n        print(temp.data, end = &quot; &quot;)\r\n        temp = temp.next\r\n        \r\ndef push(head_ref, new_data):\r\n    new_node = Node(new_data)\r\n    new_node.data = new_data\r\n    new_node.next = head_ref\r\n    head_ref = new_node\r\n    return head_ref\r\n\r\nif __name__=='__main__':\r\n    \r\n    head = LinkedList()\r\n    head = push(head, 4)\r\n    head = push(head, 3)\r\n    head = push(head, 2)\r\n    head = push(head, 1)\r\n\r\n    print(&quot;Given linked list&quot;)\r\n    printList()\r\n\r\n    head = reverse(head)\r\n\r\n    print(&quot;&#92;nReversed Linked list&quot;)\r\n    printList()\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_3641 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_3641 a\"),jQuery(\"#tab-content_3641\"));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<h4>Output<\/h4>\n<p><strong>Given linked list<\/strong><br \/>\n1 2 3 4<br \/>\n<strong>Reversed Linked list<\/strong><br \/>\n4 3 2 1<\/p>\n<p>[forminator_quiz id=&#8221;3640&#8243;]<\/p>\n<p><strong>Space Complexity:<\/strong> O(n), space required for recursion stack.<\/p>\n<p>So, in this article, we have tried to explain the most efficient approach to recursively reverse a linked list. This is an important question when it comes to coding interviews. If you want to solve more questions on Linked List, which are 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","protected":false},"excerpt":{"rendered":"<p>Introduction The linked list is one of the most important concepts and data structures to learn while preparing for interviews. Having a good grasp of Linked Lists can be a huge plus point in a coding interview. Problem Statement In this question, we are given a singly linked list. We have to reverse the 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-3639","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>Recursively Reversing A Linked List A Simple Implementation<\/title>\n<meta name=\"description\" content=\"Learn the most efficient way to recursively reverse a linked list. This blog explains the most efficient approach to recursively reverse a linked list.\" \/>\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\/recursively-reversing-a-linked-list-a-simple-implementation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Recursively Reversing A Linked List A Simple Implementation\" \/>\n<meta property=\"og:description\" content=\"Learn the most efficient way to recursively reverse a linked list. This blog explains the most efficient approach to recursively reverse a linked list.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/\" \/>\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-06T11:39:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-08T12:18:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925754905-102.Recursively%20Reversing%20A%20Linked%20List_Artboard%203.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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Recursively reversing a Linked List &#8211; A simple implementation\",\"datePublished\":\"2021-08-06T11:39:24+00:00\",\"dateModified\":\"2022-03-08T12:18:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/\"},\"wordCount\":470,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925754905-102.Recursively%20Reversing%20A%20Linked%20List_Artboard%203.png\",\"articleSection\":[\"Linked list articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/\",\"name\":\"Recursively Reversing A Linked List A Simple Implementation\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925754905-102.Recursively%20Reversing%20A%20Linked%20List_Artboard%203.png\",\"datePublished\":\"2021-08-06T11:39:24+00:00\",\"dateModified\":\"2022-03-08T12:18:01+00:00\",\"description\":\"Learn the most efficient way to recursively reverse a linked list. This blog explains the most efficient approach to recursively reverse a linked list.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925754905-102.Recursively%20Reversing%20A%20Linked%20List_Artboard%203.png\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925754905-102.Recursively%20Reversing%20A%20Linked%20List_Artboard%203.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#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\":\"Recursively reversing a Linked List &#8211; A simple implementation\"}]},{\"@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":"Recursively Reversing A Linked List A Simple Implementation","description":"Learn the most efficient way to recursively reverse a linked list. This blog explains the most efficient approach to recursively reverse a linked list.","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\/recursively-reversing-a-linked-list-a-simple-implementation\/","og_locale":"en_US","og_type":"article","og_title":"Recursively Reversing A Linked List A Simple Implementation","og_description":"Learn the most efficient way to recursively reverse a linked list. This blog explains the most efficient approach to recursively reverse a linked list.","og_url":"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2021-08-06T11:39:24+00:00","article_modified_time":"2022-03-08T12:18:01+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925754905-102.Recursively%20Reversing%20A%20Linked%20List_Artboard%203.png","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Recursively reversing a Linked List &#8211; A simple implementation","datePublished":"2021-08-06T11:39:24+00:00","dateModified":"2022-03-08T12:18:01+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/"},"wordCount":470,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925754905-102.Recursively%20Reversing%20A%20Linked%20List_Artboard%203.png","articleSection":["Linked list articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/","url":"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/","name":"Recursively Reversing A Linked List A Simple Implementation","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925754905-102.Recursively%20Reversing%20A%20Linked%20List_Artboard%203.png","datePublished":"2021-08-06T11:39:24+00:00","dateModified":"2022-03-08T12:18:01+00:00","description":"Learn the most efficient way to recursively reverse a linked list. This blog explains the most efficient approach to recursively reverse a linked list.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925754905-102.Recursively%20Reversing%20A%20Linked%20List_Artboard%203.png","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925754905-102.Recursively%20Reversing%20A%20Linked%20List_Artboard%203.png"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/recursively-reversing-a-linked-list-a-simple-implementation\/#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":"Recursively reversing a Linked List &#8211; A simple implementation"}]},{"@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\/3639","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=3639"}],"version-history":[{"count":5,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/3639\/revisions"}],"predecessor-version":[{"id":7822,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/3639\/revisions\/7822"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=3639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=3639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=3639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}