{"id":3836,"date":"2021-08-12T09:56:49","date_gmt":"2021-08-12T09:56:49","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=3836"},"modified":"2022-11-22T07:21:48","modified_gmt":"2022-11-22T07:21:48","slug":"delete-alternate-nodes-of-a-linked-list","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/","title":{"rendered":"Delete Alternate Nodes Of A Linked List"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645186675257-delete%20alternate%20nodes_Artboard%202_Artboard%202.png\" alt=\"\" \/><\/p>\n<p>We have seen various approaches and various types of deletion in linked lists such as Deleting a linked list, deleting the first node of linked list, deleting the last node of linked list, deleting the middle node of linked list and deleting the smaller and larger nodes of linked list. Now in the below article we will see how to delete alternate nodes of a linked list.<\/p>\n<h2>How to Delete Alternate Nodes of a Linked List.<\/h2>\n<p>Given a singly linked list. Remove its alternate nodes.<\/p>\n<p><strong>Example<\/strong><\/p>\n<pre><code>Sample Input: 3->5->2->6->8\nSample Output: 3->2->8\n\nHere 5 and 6 were the nodes at alternate positions. So, we have removed them.\n\nSample Input: 3->5->2->6->8->7\nSample Output: 3->2->8\n\nHere 5, 6, and 7 were nodes at alternate positions. So, we have removed them.<\/code><\/pre>\n<p>In this problem, we have to delete alternate nodes of the given linked list. Deleting alternate nodes means deleting nodes at alternate positions in the linked list.<\/p>\n<p>Let\u2019s understand this:<br \/>\nConsider a linked list 3-&gt;5-&gt;2-&gt;6-&gt;8-&gt;7 and lets mark the positions of the node (Using 1 based indexing).<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/indexes-01.png\" alt=\"\" \/><\/p>\n<p>If we start from position 1, the alternate nodes are at positions 2, 4, and 6.<\/p>\n<p>Can you observe something about the alternate positions?<br \/>\nNow, hopefully i think it is clear what we have to do in this problem.<\/p>\n<h2>Approach (Iterative)  of how to delete alternate nodes of a linked list<\/h2>\n<p>I hope you have understood the problem and have got a basic idea of what we are going to do.<\/p>\n<p>We can observe from the above example that the alternate positions are the positions that are even. So, deleting alternate nodes becomes deleting nodes at even positions in the linked list. To do so, the idea is simple, while iterating through the linked list we need to keep a track of the node\u2019s position and a pointer to the previous node. After reaching an even position, we just need to remove that node from the linked list and move ahead.<\/p>\n<p>Since it is clear what we need to do, take some time and think about how we are going to do it. Below is the algorithm explaining the steps we need to take to implement our idea.<\/p>\n<h2>Algorithm  of how to delete alternate nodes of a linked list<\/h2>\n<ul>\n<li>Declare three variables: \u2018curr\u2019, \u2018position\u2019 and \u2018prev\u2019.<\/li>\n<li>Initialize position as 1 and prev as \u2018NULL\u2019 and \u2018curr\u2019 to head.<\/li>\n<li>Iterate through the linked list using curr and update positions and prev.<\/li>\n<li>If we reach an even position, delete the node at that position from the linked list by connecting the previous node to the next node of curr and deleting the current node, and move ahead.<\/li>\n<\/ul>\n<h3>Dry Run  of how to delete alternate nodes of a linked list<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/Delete-Alternate-Nodes-Of-A-Linked-List-1-01.png\" alt=\"\" \/><\/p>\n<h2>Code Implementation  of how to delete alternate nodes of a 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_3837 {\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_3837 .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_3837 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_3837 .wpsm_nav-tabs > li.active > a, #tab_container_3837 .wpsm_nav-tabs > li.active > a:hover, #tab_container_3837 .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_3837 .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_3837 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_3837 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_3837 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_3837 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_3837 .wpsm_nav-tabs > li > a:hover , #tab_container_3837 .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_3837 .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_3837 .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_3837 .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_3837 .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_3837 .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_3837 .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_3837 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_3837 .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_3837 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_3837 .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_3837 .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_3837\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_3837\">\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_3837_1\" aria-controls=\"tabs_desc_3837_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_3837_2\" aria-controls=\"tabs_desc_3837_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_3837_3\" aria-controls=\"tabs_desc_3837_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_3837_4\" aria-controls=\"tabs_desc_3837_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_3837\">\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_3837_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\r\n#include&lt;stdio.h&gt;\r\n#include&lt;stdlib.h&gt;\r\n \r\nstruct Node\r\n{\r\n    int data;\r\n    struct Node *next;\r\n};\r\n \r\nvoid deleteAlt(struct Node *head)\r\n{\r\n    if (head == NULL)\r\n        return;\r\n \r\n    struct Node *prev = head;\r\n    struct Node *node = head-&gt;next;\r\n \r\n    while (prev != NULL &amp;&amp; node != NULL)\r\n    {\r\n        prev-&gt;next = node-&gt;next;\r\n \r\n        free(node);\r\n \r\n        prev = prev-&gt;next;\r\n        if (prev != NULL)\r\n            node = prev-&gt;next;\r\n    }\r\n}\r\n \r\nvoid push(struct Node** head_ref, int new_data)\r\n{\r\n    struct Node* new_node =\r\n        (struct Node*) malloc(sizeof(struct Node));\r\n \r\n    new_node-&gt;data  = new_data;\r\n \r\n    new_node-&gt;next = (*head_ref);\r\n \r\n    (*head_ref)    = new_node;\r\n}\r\n \r\nvoid printList(struct Node *node)\r\n{\r\n    while (node != NULL)\r\n    {\r\n        printf(&quot;%d &quot;, node-&gt;data);\r\n        node = node-&gt;next;\r\n    }\r\n}\r\n \r\nint main()\r\n{\r\n    struct Node* head = NULL;\r\n\r\n    push(&amp;head, 50);\r\n    push(&amp;head, 40);\r\n    push(&amp;head, 30);\r\n    push(&amp;head, 20);\r\n    push(&amp;head, 10);\r\n \r\n    printf(&quot;&#92;nList before delete &#92;n&quot;);\r\n    printList(head);\r\n \r\n    deleteAlt(head);\r\n \r\n    printf(&quot;&#92;nList after delete &#92;n&quot;);\r\n    printList(head);\r\n \r\n    return 0;\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\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_3837_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;bits stdc++.h=&quot;&quot;&gt;\r\nusing namespace std;\r\n\r\nstruct Node {\r\n    int val;\r\n    Node* next;\r\n\r\n    Node(int value){\r\n        val = value;\r\n        next = NULL;\r\n    }\r\n};\r\n\r\nvoid push_front(Node** head, int new_val){\r\n    Node* new_node = new Node(new_val);\r\n    new_node-&gt;next = *head;\r\n    *head = new_node;\r\n}\r\n\r\nvoid printList(Node* head){\r\n    Node* i = head;\r\n    while(i){\r\n        cout&lt;&lt;i-&gt;val&lt;&lt;&quot; &quot;;\r\n        i = i-&gt;next;\r\n    }\r\n    cout&lt;&lt;&quot;&#92;n&quot;;\r\n}\r\n\r\nvoid delete_alt_nodes(Node* head){\r\n    \r\n    int position = 1;\r\n    Node *prev = NULL;\r\n    \r\n    Node *curr = head;\r\n    while(curr != NULL){\r\n        if(position%2==0){\r\n            \/\/ delete curr\r\n            prev-&gt;next = curr-&gt;next;\r\n            Node *temp = curr;\r\n            curr = curr-&gt;next;\r\n            delete temp;\r\n        }\r\n        else {\r\n            prev = curr;\r\n            curr = curr-&gt;next;\r\n        }\r\n        position ++;\r\n    }\r\n}\r\n\r\nint main(){\r\n    Node* head = NULL;\r\n    push_front(&amp;head, 8);\r\n    push_front(&amp;head, 6);\r\n    push_front(&amp;head, 2);\r\n    push_front(&amp;head, 5);\r\n    push_front(&amp;head, 3);\r\n    \r\n    cout&lt;&lt;&rdquo;Original list:&#92;n&rdquo;;\r\n    printList(head);\r\n    \/\/ 3 5 2 6 8\r\n\r\n    delete_alt_nodes(head);\r\n    \r\n    cout&lt;&lt;&rdquo;After deleting alternate nodes:&#92;n&rdquo;;\r\n    printList(head);\r\n    \/\/ 3 2 8\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_3837_3\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"java\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n\r\n\/\/ Java program to delete alternate nodes of a linked list\r\nclass AlternateNodes\r\n{\r\n\tstatic Node head; \/\/ head of list\r\n\r\n\t\/* Linked list Node*\/\r\n\tclass Node\r\n\t{\r\n\t\tint data;\r\n\t\tNode next;\r\n\t\tNode(int d) {data = d; next = null; }\r\n\t}\r\n\r\n\tvoid deleteAlt()\r\n\t{\r\n\tif (head == null)\r\n\t\treturn;\r\n\r\n\tNode prev = head;\r\n\tNode now = head.next;\r\n\r\n\twhile (prev != null &amp;&amp; now != null)\r\n\t{\t\t\r\n\t\t\/* Change next link of previous node *\/\r\n\t\tprev.next = now.next;\r\n\r\n\t\t\/* Free node *\/\r\n\t\tnow = null;\r\n\r\n\t\t\/*Update prev and now *\/\r\n\t\tprev = prev.next;\r\n\t\tif (prev != null)\r\n\t\t\tnow = prev.next;\r\n\t}\r\n\t}\t\t\t\t\r\n\r\n\t\t\t\t\t\r\n\t\/* Utility functions *\/\r\n\r\n\t\/* Inserts a new Node at front of the list. *\/\r\n\tpublic void push(int new_data)\r\n\t{\r\n\t\t\/* 1 &amp; 2: Allocate the Node &amp;\r\n\t\t\t\tPut in the data*\/\r\n\t\tNode new_node = new Node(new_data);\r\n\r\n\t\t\/* 3. Make next of new Node as head *\/\r\n\t\tnew_node.next = head;\r\n\r\n\t\t\/* 4. Move the head to point to new Node *\/\r\n\t\thead = new_node;\r\n\t}\r\n\r\n\t\/* Function to print linked list *\/\r\n\tvoid printList()\r\n\t{\r\n\t\tNode temp = head;\r\n\t\twhile(temp != null)\r\n\t\t{\r\n\t\tSystem.out.print(temp.data+&quot; &quot;);\r\n\t\ttemp = temp.next;\r\n\t\t}\r\n\t\tSystem.out.println();\r\n\t}\r\n\r\n\t\/* Driver program to test above functions *\/\r\n\tpublic static void main(String args[])\r\n\t{\r\n\t\tAlternateNodes llist = new AlternateNodes();\r\n\t\t\r\n\t\t\/* Constructed Linked List is 1-&gt;2-&gt;3-&gt;4-&gt;5-&gt;null *\/\r\n\t\tllist.push(8);\r\n\t\tllist.push(6);\r\n\t\tllist.push(2);\r\n\t\tllist.push(5);\r\n\t\tllist.push(3);\r\n\t\t\r\n\t\tSystem.out.println(&quot;Linked List before calling deleteAlt() &quot;);\r\n\t\tllist.printList();\r\n\t\t\r\n\t\tllist.deleteAlt();\r\n\t\t\r\n\t\tSystem.out.println(&quot;Linked List after calling deleteAlt() &quot;);\r\n\t\tllist.printList();\r\n\t}\r\n}\r\n\r\n\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\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_3837_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\tdef __init__(self, data):\r\n\t\tself.data = data\r\n\t\tself.next = None\r\ndef deleteAlt(head):\r\n\tif (head == None):\r\n\t\treturn\r\n\r\n\tprev = head\r\n\tnow = head.next\r\n\r\n\twhile (prev != None and now != None):\r\n\t\t\r\n\t\tprev.next = now.next\r\n\t\tnow = None\r\n\t\tprev = prev.next\r\n\t\tif (prev != None):\r\n\t\t\tnow = prev.next\r\n\r\ndef push(head_ref, new_data):\r\n\t\r\n\tnew_node = Node(new_data)\r\n\tnew_node.data = new_data\r\n\tnew_node.next = head_ref\r\n\thead_ref = new_node\r\n\treturn head_ref\r\n\r\ndef printList(node):\r\n\twhile (node != None):\r\n\t\tprint(node.data, end = &quot; &quot;)\r\n\t\tnode = node.next\r\n\t\r\nif __name__=='__main__':\r\n\t\r\n\thead = None\r\n\r\n\thead = push(head, 8)\r\n\thead = push(head, 6)\r\n\thead = push(head, 2)\r\n\thead = push(head, 5)\r\n\thead = push(head, 3)\r\n\r\n\tprint(&quot;List before calling deleteAlt() &quot;)\r\n\tprintList(head)\r\n\r\n\tdeleteAlt(head)\r\n\r\n\tprint(&quot;&#92;nList after calling deleteAlt() &quot;)\r\n\tprintList(head)\r\n\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\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_3837 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_3837 a\"),jQuery(\"#tab-content_3837\"));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\nOriginal list: 3 5 2 6 8\nAfter deleting alternate nodes: 3 2 8<\/code><\/pre>\n<p><strong>Time complexity to delete alternate nodes of a linked list :<\/strong> O(n), where n is the number of nodes in the linked list.<\/p>\n<p><strong>Space complexity to delete alternate nodes of a linked list:<\/strong> O(1), since we don\u2019t use any extra space.<\/p>\n<p>I hope you have understood the iterative approach. Now, let\u2019s see another way to approach the problem.<\/p>\n<h2>Approach (Recursive) to delete alternate nodes of a linked list<\/h2>\n<p>We already know what deleting alternate nodes of a linked list means. <\/p>\n<p>If we start from the first node we delete the second node and fourth node and so on. Given a linked list with at least 2 nodes and a given pointer to the first node we can easily delete the second node by making the \u2018next\u2019 of the first node as next of the first. Deleting the fourth node would be the same if we consider the linked list starting from the third node. Then the node to delete would be the 2nd node in that linked list.<\/p>\n<p>Here we broke the given problem into a smaller problem. We delete the second node from the given linked list and call the same function for the linked list starting from the third node.<\/p>\n<p>Now, what will be the base case?<br \/>\nIf the linked list is empty or has only one node, we don\u2019t have a second node to delete. So, we simply return the passed linked list.<\/p>\n<p>Now that you have understood the approach, try to implement this idea yourself.<\/p>\n<h2>Algorithm to delete alternate nodes of a linked list<\/h2>\n<ul>\n<li>If the linked list is empty or has only one node, return the linked list. (Base case)<\/li>\n<li>Store the pointer to the second node in a variable \u2018second\u2019 as: second = head-&gt;next.<\/li>\n<li>Recursively call the same function for the linked list after the 2nd node and store the linked list returned as \u2018rem\u2019.<\/li>\n<li>Attach this linked list pointed by \u2018rem\u2019 to the first node as: head-&gt;next = rem<\/li>\n<li>Now the second node is disconnected from the linked list, so delete it using the delete command.<\/li>\n<li>Return the resulting linked list.<\/li>\n<\/ul>\n<h3>Dry Run to delete alternate nodes of a linked list<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/Delete-Alternate-Nodes-Of-A-Linked-List-dry-run-2-01-1.png\" alt=\"\" \/><\/p>\n<h2>Code Implementation to delete alternate nodes of a 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_3842 {\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_3842 .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_3842 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_3842 .wpsm_nav-tabs > li.active > a, #tab_container_3842 .wpsm_nav-tabs > li.active > a:hover, #tab_container_3842 .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_3842 .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_3842 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_3842 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_3842 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_3842 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_3842 .wpsm_nav-tabs > li > a:hover , #tab_container_3842 .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_3842 .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_3842 .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_3842 .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_3842 .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_3842 .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_3842 .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_3842 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_3842 .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_3842 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_3842 .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_3842 .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_3842\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_3842\">\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_3842_1\" aria-controls=\"tabs_desc_3842_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_3842_2\" aria-controls=\"tabs_desc_3842_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_3842_3\" aria-controls=\"tabs_desc_3842_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_3842_4\" aria-controls=\"tabs_desc_3842_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_3842\">\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_3842_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\r\n#include&lt;stdio.h&gt;\r\n#include&lt;stdlib.h&gt;\r\n\r\n\r\nstruct Node {\r\n    int val;\r\n    struct Node* next;\r\n\r\n};\r\n\r\nvoid push_front(struct Node* head, int new_val){\r\n    struct Node* new_node =\r\n          (struct Node*) malloc(sizeof(struct Node));\r\n    new_node-&gt;next = head;\r\n    head = new_node;\r\n}\r\n\r\nvoid printList(struct Node* head){\r\n   struct  Node* i = head;\r\n    while(i){\r\n        printf(&quot;%d &quot;,&amp;i-&gt;val);\r\n        i = i-&gt;next;\r\n    }\r\n    printf(&quot;&#92;n&quot;);\r\n}\r\n\r\n\/\/ recursive function to delete alternate nodes of a linked list\r\nstruct Node* delete_alt(struct Node* head){\r\n    \/\/ base case\r\n    if(head==NULL || head-&gt;next==NULL) return head;\r\n\r\n    struct Node* second = head-&gt;next;\r\n    struct Node* rem = delete_alt(second-&gt;next);\r\n    head-&gt;next = rem;\r\n\r\n    free(second);\r\n\r\n    return head;\r\n}\r\n\r\nint main(){\r\n    struct Node* head = NULL;\r\n\r\n    push_front(&amp;head, 8);\r\n    push_front(&amp;head, 6);\r\n    push_front(&amp;head, 2);\r\n    push_front(&amp;head, 5);\r\n    push_front(&amp;head, 3);\r\n\r\n    printList(head);\r\n    \/\/ 3 5 2 6 8\r\n\r\n    delete_alt(head);\r\n\r\n    printList(head);\r\n    \/\/ 3 2 8\r\n}\r\n\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\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_3842_2\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"cpp\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n\r\n#include&lt;bits stdc++.h=&quot;&quot;&gt;\r\nusing namespace std;\r\n\r\nstruct Node {\r\n    int val;\r\n    Node* next;\r\n\r\n    Node(int value){\r\n        val = value;\r\n        next = NULL;\r\n    }\r\n};\r\n\r\nvoid push_front(Node** head, int new_val){\r\n    Node* new_node = new Node(new_val);\r\n    new_node-&gt;next = *head;\r\n    *head = new_node;\r\n}\r\n\r\nvoid printList(Node* head){\r\n    Node* i = head;\r\n    while(i){\r\n        cout&lt;&lt;i-&gt;val&lt;&lt;&quot; &quot;;\r\n        i = i-&gt;next;\r\n    }\r\n    cout&lt;&lt;&quot;&#92;n&quot;;\r\n}\r\n\r\n\/\/ recursive function to delete alternate nodes of a linked list\r\nNode* delete_alt(Node* head){\r\n    \/\/ base case\r\n    if(head==NULL || head-&gt;next==NULL) return head;\r\n\r\n    Node* second = head-&gt;next;\r\n    Node* rem = delete_alt(second-&gt;next);\r\n    head-&gt;next = rem;\r\n\r\n    delete second;\r\n\r\n    return head;\r\n}\r\n\r\nint main(){\r\n    Node* head = NULL;\r\n\r\n    push_front(&amp;head, 8);\r\n    push_front(&amp;head, 6);\r\n    push_front(&amp;head, 2);\r\n    push_front(&amp;head, 5);\r\n    push_front(&amp;head, 3);\r\n\r\n    printList(head);\r\n    \/\/ 3 5 2 6 8\r\n\r\n    delete_alt(head);\r\n\r\n    printList(head);\r\n    \/\/ 3 2 8\r\n}\r\n\r\n\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_3842_3\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"java\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n\r\n\/\/ Java program to delete alternate nodes of a linked list\r\nclass AlternateNodes\r\n{\r\n\tstatic Node head; \/\/ head of list\r\n\r\n\t\/* Linked list Node*\/\r\n\tclass Node\r\n\t{\r\n\t\tint data;\r\n\t\tNode next;\r\n\t\tNode(int d) {data = d; next = null; }\r\n\t}\r\n\r\n\tvoid deleteAlt()\r\n\t{\r\n\tif (head == null)\r\n\t\treturn;\r\n\r\n\tNode prev = head;\r\n\tNode now = head.next;\r\n\r\n\twhile (prev != null &amp;&amp; now != null)\r\n\t{\t\t\r\n\t\t\/* Change next link of previous node *\/\r\n\t\tprev.next = now.next;\r\n\r\n\t\t\/* Free node *\/\r\n\t\tnow = null;\r\n\r\n\t\t\/*Update prev and now *\/\r\n\t\tprev = prev.next;\r\n\t\tif (prev != null)\r\n\t\t\tnow = prev.next;\r\n\t}\r\n\t}\t\t\t\t\r\n\r\n\t\t\t\t\t\r\n\t\/* Utility functions *\/\r\n\r\n\t\/* Inserts a new Node at front of the list. *\/\r\n\tpublic void push(int new_data)\r\n\t{\r\n\t\t\r\n\t\tNode new_node = new Node(new_data);\r\n\t\tnew_node.next = head;\r\n\t\thead = new_node;\r\n\t}\r\n\r\n\t\/* Function to print linked list *\/\r\n\tvoid printList()\r\n\t{\r\n\t\tNode temp = head;\r\n\t\twhile(temp != null)\r\n\t\t{\r\n\t\tSystem.out.print(temp.data+&quot; &quot;);\r\n\t\ttemp = temp.next;\r\n\t\t}\r\n\t\tSystem.out.println();\r\n\t}\r\n\r\n\t\/* Driver program to test above functions *\/\r\n\tpublic static void main(String args[])\r\n\t{\r\n\t\tAlternateNodes llist = new AlternateNodes();\r\n\t\t\r\n\t\tllist.push(8);\r\n\t\tllist.push(6);\r\n\t\tllist.push(2);\r\n\t\tllist.push(5);\r\n\t\tllist.push(3);\r\n\t\t\r\n\t\tSystem.out.println(&quot;Linked List before calling deleteAlt() &quot;);\r\n\t\tllist.printList();\r\n\t\t\r\n\t\tllist.deleteAlt();\r\n\t\t\r\n\t\tSystem.out.println(&quot;Linked List after calling deleteAlt() &quot;);\r\n\t\tllist.printList();\r\n\t}\r\n}\r\n\r\n\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\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_3842_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\tdef __init__(self, data):\r\n\t\tself.data = data\r\n\t\tself.next = None\r\n\r\ndef deleteAlt(head):\r\n\t\r\n\tif (head == None or head.next == None):\r\n\t\treturn head\r\n\r\n\tsecond = head.next\r\n\trem = deleteAlt(second.next)\r\n\thead.next = rem\r\n\tdel second\r\n\t\r\n\treturn  head\t\r\n\r\ndef push(head_ref, new_data):\r\n\t\r\n\tnew_node = Node(new_data)\r\n\tnew_node.data = new_data\r\n\tnew_node.next = head_ref\r\n\thead_ref = new_node\r\n\treturn head_ref\r\n\r\ndef printList(node):\r\n\twhile (node != None):\r\n\t\tprint(node.data, end = &quot; &quot;)\r\n\t\tnode = node.next\r\n\t\r\nif __name__=='__main__':\r\n\t\r\n\thead = None\r\n\r\n\thead = push(head, 8)\r\n\thead = push(head, 6)\r\n\thead = push(head, 2)\r\n\thead = push(head, 5)\r\n\thead = push(head, 3)\r\n\r\n\tprint(&quot;List before calling deleteAlt() &quot;)\r\n\tprintList(head)\r\n\r\n\tdeleteAlt(head)\r\n\r\n\tprint(&quot;&#92;nList after calling deleteAlt() &quot;)\r\n\tprintList(head)\r\n\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\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_3842 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_3842 a\"),jQuery(\"#tab-content_3842\"));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\nOriginal list: 3 5 2 6 8\nAfter deleting alternate nodes: 3 2 8<\/code><\/pre>\n<p><strong>Space Complexity:<\/strong> O(n), due to function call stack, where n is the number of nodes in the linked list.<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>In the above article, we have seen how to initialize the singly linked list with dummy data and iterating through the list by maintaining the previous node and then deleting the alternate nodes. I would highly recommend you to practice more such problems from <a href=\"https:\/\/mycode.prepbytes.com\/interview-coding\/practice\/linked-list\">Linked List<\/a>.<\/p>\n<h2>FAQs<\/h2>\n<p><strong>1. Enlist the types of linked list?<\/strong><\/p>\n<ul>\n<li>Singly linked list<\/li>\n<li>Doubly linked linked list<\/li>\n<li>Circular linked list<\/li>\n<li>Circular doubly linked list<\/li>\n<\/ul>\n<p><strong>2. Why is linked list preferred over other data structures?<\/strong><br \/>\nLinked lists are preferred because of their efficient insertion and deletion , the other thing is the dynamic nature of linked lists.<\/p>\n<p><strong>3. Why is insertion faster in the linked list ?<\/strong><br \/>\nAs we already know that the linked list is dynamic in nature and there is just a rearrangement of pointers, no shifting and all.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have seen various approaches and various types of deletion in linked lists such as Deleting a linked list, deleting the first node of linked list, deleting the last node of linked list, deleting the middle node of linked list and deleting the smaller and larger nodes of linked list. Now in the below article [&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-3836","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>Delete Alternate Nodes Of A Linked List in C++ | Linked List | Prepbytes<\/title>\n<meta name=\"description\" content=\"Learn to delete the alternate nodes of a given linked list. This blog explains how to delete alternate nodes of 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\/delete-alternate-nodes-of-a-linked-list\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Delete Alternate Nodes Of A Linked List in C++ | Linked List | Prepbytes\" \/>\n<meta property=\"og:description\" content=\"Learn to delete the alternate nodes of a given linked list. This blog explains how to delete alternate nodes of a linked list.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-12T09:56:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-22T07:21:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645186675257-delete%20alternate%20nodes_Artboard%202_Artboard%202.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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Delete Alternate Nodes Of A Linked List\",\"datePublished\":\"2021-08-12T09:56:49+00:00\",\"dateModified\":\"2022-11-22T07:21:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/\"},\"wordCount\":962,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645186675257-delete%20alternate%20nodes_Artboard%202_Artboard%202.png\",\"articleSection\":[\"Linked list articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/\",\"name\":\"Delete Alternate Nodes Of A Linked List in C++ | Linked List | Prepbytes\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645186675257-delete%20alternate%20nodes_Artboard%202_Artboard%202.png\",\"datePublished\":\"2021-08-12T09:56:49+00:00\",\"dateModified\":\"2022-11-22T07:21:48+00:00\",\"description\":\"Learn to delete the alternate nodes of a given linked list. This blog explains how to delete alternate nodes of a linked list.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645186675257-delete%20alternate%20nodes_Artboard%202_Artboard%202.png\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645186675257-delete%20alternate%20nodes_Artboard%202_Artboard%202.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-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\":\"Delete Alternate Nodes Of A Linked List\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Delete Alternate Nodes Of A Linked List in C++ | Linked List | Prepbytes","description":"Learn to delete the alternate nodes of a given linked list. This blog explains how to delete alternate nodes of 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\/delete-alternate-nodes-of-a-linked-list\/","og_locale":"en_US","og_type":"article","og_title":"Delete Alternate Nodes Of A Linked List in C++ | Linked List | Prepbytes","og_description":"Learn to delete the alternate nodes of a given linked list. This blog explains how to delete alternate nodes of a linked list.","og_url":"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2021-08-12T09:56:49+00:00","article_modified_time":"2022-11-22T07:21:48+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645186675257-delete%20alternate%20nodes_Artboard%202_Artboard%202.png","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Delete Alternate Nodes Of A Linked List","datePublished":"2021-08-12T09:56:49+00:00","dateModified":"2022-11-22T07:21:48+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/"},"wordCount":962,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645186675257-delete%20alternate%20nodes_Artboard%202_Artboard%202.png","articleSection":["Linked list articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/","url":"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/","name":"Delete Alternate Nodes Of A Linked List in C++ | Linked List | Prepbytes","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645186675257-delete%20alternate%20nodes_Artboard%202_Artboard%202.png","datePublished":"2021-08-12T09:56:49+00:00","dateModified":"2022-11-22T07:21:48+00:00","description":"Learn to delete the alternate nodes of a given linked list. This blog explains how to delete alternate nodes of a linked list.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-linked-list\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645186675257-delete%20alternate%20nodes_Artboard%202_Artboard%202.png","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645186675257-delete%20alternate%20nodes_Artboard%202_Artboard%202.png"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/delete-alternate-nodes-of-a-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":"Delete Alternate Nodes Of A Linked List"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/3836","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=3836"}],"version-history":[{"count":6,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/3836\/revisions"}],"predecessor-version":[{"id":10678,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/3836\/revisions\/10678"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=3836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=3836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=3836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}