

{"id":94985,"date":"2021-05-21T09:00:04","date_gmt":"2021-05-21T03:30:04","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=94985"},"modified":"2021-05-14T18:37:40","modified_gmt":"2021-05-14T13:07:40","slug":"linked-list-in-data-structure","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/","title":{"rendered":"Linked List in Data Structure"},"content":{"rendered":"<p>In computer science, we refer to the format of storing data on storage devices as a data structure. An array is the collection of data stored in contiguous memory locations.<\/p>\n<p>This makes accessibility very easy but it leads to not so efficient use of memory because the smaller chunks of memory that are left between earlier stored data are not used.<\/p>\n<p>But what if you need more efficient utilization of your memory. Here dynamic data structures come into the picture. Dynamic data structures as the name suggest do not have a fixed memory size.<\/p>\n<p>They can shrink or grow themselves by deallocating or allocating the memory respectively, as and when required.<\/p>\n<p>In this article, we will learn about the most basic dynamic data structures, Linked list, their types, and how to do basic operations on a linked list.<\/p>\n<h3>Linked List in Data Structure<\/h3>\n<p>A linked list is the most basic type of dynamic data structure. A linked list is a linear collection of data where the order of elements is not given by their physical memory address. The user stores the data in blocks of memory called nodes.<\/p>\n<p>Each node has two parts. The first part contains the data and the second part points towards the next node. It contains the address of the next node in the actual memory.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-95319\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image01.jpg\" alt=\"Linked List in Data Structure\" width=\"1200\" height=\"450\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image01-300x113.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image01-1024x384.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image01-150x56.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image01-768x288.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image01-720x270.jpg 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image01-520x195.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image01-320x120.jpg 320w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<h3>Types of Linked Lists<\/h3>\n<h4>1. Singly Linked list<\/h4>\n<p><span style=\"font-weight: 400;\">Singly-linked lists are the most basic and easy to implement linked lists. Each node stores the data at random memory locations and contains a pointer that points to the next node in the memory.<\/span><\/p>\n<h4>2. Doubly linked list<\/h4>\n<p><span style=\"font-weight: 400;\">Each node contains data and two pointers. One point to the previous node and the other points to the next node. This makes doubly-linked traversable both forward and backward.<\/span><\/p>\n<h4>3. Circular linked list<\/h4>\n<p><span style=\"font-weight: 400;\">Just like a singly linked list, here also each node is linked to the next only with a slight modification. In a circular linked list, the last node of the list is pointed to the first node forming a loop. So we can reach the previous node by traversing forward.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In this article, we will be learning about Singly-linked lists only. We will learn about other types in detail in future articles.<\/span><\/p>\n<h3>Singly Linked list in Data Structure<\/h3>\n<p>A singly linked list as we have seen contains multiple nodes in which the earlier node points at the next node except the last node. A node has two parts, the first one contains the data and the second part contains the address of the next node.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image02.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-95321\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image02.jpg\" alt=\"Singly Linked List\" width=\"1200\" height=\"350\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image02.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image02-300x88.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image02-1024x299.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image02-150x44.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image02-768x224.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image02-720x210.jpg 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image02-520x152.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image02-320x93.jpg 320w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<h3>Creating Node in Linked List<\/h3>\n<p>C program for creating a Linked List Node:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">struct node   \r\n{  \r\n    int data;                 \/\/ data to store in node\r\n    struct node *next;   \/\/NULL for last node\r\n}  \r\n<\/pre>\n<p>The previous part of the first node and the next part of the last node will always have NULL.<\/p>\n<h3>Need of Pointers in Linked List<\/h3>\n<p>Unlike arrays, in a linked list, memory allocation takes place at runtime and therefore memory location of each node is random. Each node can be present anywhere in the memory and to access them, each node has the address of its next node stored with it.<\/p>\n<p>This forms a kind of link between every node. This is the additional pointer that we need because if the link is not present or it&#8217;s broken, the memory locations will be lost.<\/p>\n<h3>Basic Linked List Operations<\/h3>\n<ul>\n<li style=\"font-weight: 400;\"><b>Insert:<\/b><span style=\"font-weight: 400;\"> Insert the node at any position. Worst-case time complexity O(1).<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>Delete:<\/b><span style=\"font-weight: 400;\"> Delete the node at any position. Worst-case time complexity O(1).<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>Search: <\/b><span style=\"font-weight: 400;\">Search for a specific node in the list. The worst-case time complexity O(n).<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>Display:<\/b><span style=\"font-weight: 400;\"> Display a complete list. The worst-case time complexity O(n).<\/span><\/li>\n<\/ul>\n<h3>Adding Nodes in Linked List<\/h3>\n<p>Adding nodes in a linked list can be sometimes tricky. Since a linked list is a dynamic data structure, we can not just break a link and add or delete the node anywhere. To better understand this let us do a thought experiment.<\/p>\n<p>Consider a linked list similar to a train with multiple coaches. Each coach represents the first part of the node where data is present, here passengers. The next part of the coach, i.e. the coupling represents the second part of the node. This part contains a connection to the next node.<\/p>\n<p>Now, if you want to add a new coach to a moving train you cannot simply uncouple any two coaches and add a new coach. As soon as you uncouple the coaches, the second part of the train which is not attached to the engine will be left behind and that will fail the task.<\/p>\n<p>Similarly, in the linked list, we cannot just break a link between any two nodes and add a new node. Suppose you want to add a new node between the fourth and fifth nodes. To do that you first have to traverse from the first node to the fifth node.<\/p>\n<p>Point the new node to the fifth node and then traverse again from the start to the fourth node. Point the fourth node towards the new node. The new node is now a part of the linked list.<\/p>\n<h4>1. Insert node at the beginning<\/h4>\n<p><span style=\"font-weight: 400;\">Create a new node and point it to the first node.<\/span><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image03.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-95322\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image03.jpg\" alt=\"Adding node in Linked List\" width=\"1200\" height=\"450\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image03.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image03-300x113.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image03-1024x384.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image03-150x56.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image03-768x288.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image03-720x270.jpg 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image03-520x195.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image03-320x120.jpg 320w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">void insertAtBegin(node *new) \r\n{\r\n  new-&gt;next = head;\r\n  head = new;\r\n }<\/pre>\n<h4>2. Insert node at position \u2018n\u2019<\/h4>\n<p><span style=\"font-weight: 400;\">Link new node to n<\/span><span style=\"font-weight: 400;\">th<\/span><span style=\"font-weight: 400;\"> node, traverse to (n-1)<\/span><span style=\"font-weight: 400;\">th<\/span><span style=\"font-weight: 400;\"> node, point (n-1)<\/span><span style=\"font-weight: 400;\">th<\/span><span style=\"font-weight: 400;\"> node to new node.<\/span><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image04.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-95323\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image04.jpg\" alt=\"Insert node at n Position in Linked List\" width=\"1200\" height=\"450\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image04.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image04-300x113.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image04-1024x384.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image04-150x56.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image04-768x288.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image04-720x270.jpg 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image04-520x195.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image04-320x120.jpg 320w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Void insertAtPosition(node *new, node *previous)\r\n{\r\n    new -&gt; next = previous -&gt; next;\r\n    previous -&gt; next = new;\r\n}<\/pre>\n<h4>3. Insert node at last<\/h4>\n<p><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Point the last node to the new node and point the new node to NULL.<\/span><\/span><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image05.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-95324\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image05.jpg\" alt=\"Insert node at last in Linked List\" width=\"1200\" height=\"450\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image05.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image05-300x113.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image05-1024x384.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image05-150x56.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image05-768x288.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image05-720x270.jpg 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image05-520x195.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image05-320x120.jpg 320w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Void insertAtEnd(node *new)\r\n{\r\n    while (last -&gt; next != NULL)\r\n               last = last -&gt; next;\r\n    last -&gt; next = new;\r\n    new -&gt; next = NULL;\r\n}<\/pre>\n<h3><span style=\"font-size: 16px;\">Deleting nodes in Linked List<\/span><\/h3>\n<h4>1. Delete the first Node in Linked List<\/h4>\n<p><span style=\"font-weight: 400;\">Point \u2018prev\u2019 of the second node to NULL.<\/span><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image06.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-95325\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image06.jpg\" alt=\"Delete first node in linked list\" width=\"1200\" height=\"450\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image06.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image06-300x113.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image06-1024x384.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image06-150x56.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image06-768x288.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image06-720x270.jpg 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image06-520x195.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image06-320x120.jpg 320w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">void DeleteAtFirst()\r\n{\r\n     Node *temp  = *head;   \r\n     head = temp -&gt; next;\r\n     free(temp);\r\n    \r\n}<\/pre>\n<h4>2. Delete node at position \u2018n\u2019 in Linked List<\/h4>\n<p><span style=\"font-weight: 400;\">Traverse to the node at the \u2018n-1\u2019 position and point it to the \u2018n+1\u2019 node. Delink node at position \u2018n\u2019 and \u2018n+1\u2019.<\/span><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image07.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-95326\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image07.jpg\" alt=\"delete node at n position in linked list\" width=\"1200\" height=\"500\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image07.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image07-300x125.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image07-1024x427.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image07-150x63.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image07-768x320.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image07-720x300.jpg 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image07-520x217.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image07-320x133.jpg 320w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">void DeleteAtPosition(int pos)  \r\n{  \r\n    struct node *ptr,*ptr1;   \r\n    ptr=head;  \r\n    for(i=0;i&lt;pos;i++)  \r\n    {  \r\n        ptr1 = ptr;       \r\n        ptr = ptr-&gt;next;  \r\n    }  \r\n    ptr1 -&gt;next = ptr -&gt;next;  \r\n    free(ptr);   \r\n}<\/pre>\n<h4>3. Delete the node at last position<\/h4>\n<p><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Point the second last node to null.<\/span><\/span><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image08.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-95327\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image08.jpg\" alt=\"delete last node in linked list\" width=\"1200\" height=\"400\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image08.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image08-300x100.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image08-1024x341.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image08-150x50.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image08-768x256.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image08-720x240.jpg 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image08-520x173.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS-normla-image08-320x107.jpg 320w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">void DeleteAtLast()\r\n{\r\n     Node *ptr, *ptr1;\r\n     ptr = head;\r\n     while (ptr -&gt; next != NULL)\r\n     {\r\n          ptr1 = ptr;\r\n          ptr = ptr -&gt; next;\r\n     }\r\n     ptr1 -&gt; next =NULL;\r\n     free ptr;   \r\n}<\/pre>\n<h3>Search node in Linked List<\/h3>\n<p><span style=\"font-weight: 400;\">Searching for an element in the linked list. We compare the data of each node to the search element and return the location if found. If not found return -1.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Boolean flag= false;\r\nbool search(struct Node* head, int x)\r\n{\r\n    struct Node* current = head;\r\n    while (current != NULL)\r\n    {\r\n        if (current-&gt;key == x)\r\n          {\r\n            flag = true;\r\n            break;\r\n    }\r\n}\r\n    return flag;\r\n}\r\n<\/pre>\n<h3>Traversing the linked list<\/h3>\n<p>Move the control pointer from the first node to the last node via each node in between and display data of each node.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Int traverse(struct Node* head)\r\n{\r\n    struct Node* current = head;\r\n    while (current != NULL)\r\n    {\r\n        return current -&gt; data;\r\n    }\r\n}<\/pre>\n<h3>Reversing a linked list<\/h3>\n<p>We need the head to point at the last node and the first node to point at NULL. In between all nodes will be pointing to their previous node in the original linked list.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">void reverse(struct Node** head)\r\n{\r\n    struct Node* previous = NULL;\r\n    struct Node* current = *head;\r\n    struct Node* next = NULL;\r\n    while (current != NULL) \r\n{\r\n        next = current-&gt;next;    \r\n        current-&gt;next = previous;\r\n        previous = current;\r\n        current = next;\r\n    }\r\n    *head = previous;\r\n}<\/pre>\n<h3>Linked list implementation in C<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#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\nint main()\r\n{\r\n    struct Node* Node1 = NULL;\r\n    struct Node* Node2 = NULL;\r\n    struct Node* Node3 = NULL;\r\n  \r\n    \r\n   Node1 = (struct Node*)malloc(sizeof(struct Node));\r\n   Node2 = (struct Node*)malloc(sizeof(struct Node));\r\n   Node3 = (struct Node*)malloc(sizeof(struct Node));\r\n  \r\n     \r\n    Node1 -&gt; data = 1; \r\n    Node1 -&gt; next = Node2;   \r\n       \r\n    Node2 -&gt; data = 2;\r\n    Node2 -&gt; next = Node3;\r\n  \r\n     \r\n    Node3 -&gt; data = 3; \r\n    Node3 -&gt; next = NULL;\r\n  \r\n    display(Node1);\r\n    return 0;\r\n}\r\n\r\nvoid display(struct Node* disp)\r\n{\r\n    while (disp != NULL) \r\n{\r\n        printf(\" %d \", disp -&gt; data);\r\n        disp = disp -&gt; next;\r\n    }\r\n}<\/pre>\n<h3>Linked list implementation in Python<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">class Node:\r\n    def __init__(self, data):\r\n        self.data = data  \r\n        self.next = None  \r\n  \r\nclass SinglyLinkedList:    \r\n    def __init__(self):\r\n        self.head = None\r\n    \r\n    def DsiplayList(self):\r\n        temp = self.head\r\n        while (temp):\r\n            print (temp.data)\r\n            temp = temp.next\r\n  \r\nif __name__=='__main__':\r\n  \r\n    sll = SinglyLinkedList()\r\n  \r\n    sll.head = Node(1)\r\n    Node2 = Node(2)\r\n    Node3 = Node(3)\r\n  \r\n    sll.head.next = Node2; \r\n    Node2.next = Node3; \r\n  \r\n    llist.DisplayList()<\/pre>\n<h3>Implementation of Linked List in C++<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;bits\/stdc++.h&gt;\r\nusing namespace std;\r\n  \r\nclass Node {\r\npublic:\r\n    int data;\r\n    Node* next;\r\n};\r\n  \r\nvoid displayList(Node* n)\r\n{\r\n    while (n != NULL)\r\n {\r\n        cout &lt;&lt; n -&gt; data &lt;&lt; \" \";\r\n        n = n -&gt; next;\r\n    }\r\n}\r\n \r\nint main()\r\n{\r\n    Node* Node1 = NULL;\r\n    Node* Node2 = NULL;\r\n    Node* Node3 = NULL;\r\n  \r\n    Node1 = new Node();\r\n    Node2 = new Node();\r\n    Node3 = new Node();\r\n  \r\n    Node1 -&gt; data = 1; \r\n    Node1 -&gt; next = Node2; \r\n  \r\n    Node2 -&gt; data = 2; \r\n    Node2 -&gt; next = Node3;\r\n  \r\n    Node3 -&gt; data = 3; \r\n    Node3 -&gt; next = NULL;\r\n  \r\n    displayList(Node1);\r\n  \r\n    return 0;\r\n}<\/pre>\n<h3>Linked list implementation in Java<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">class SinglyLinkedList\r\n {\r\n    \r\nNode head; \r\n \r\n    static class Node\r\n   {\r\n        int data;\r\n        Node next;\r\n        \r\n        Node(int d)\r\n        {\r\n            data = d;\r\n            next = null;\r\n        } \r\n    }\r\n  \r\n    \r\n    public void DisplayList()\r\n    {\r\n        Node n = head;\r\n        while (n != null) \r\n        {\r\n            System.out.print(n.data + \" \");\r\n            n = n.next;\r\n        }\r\n    }\r\n  \r\n    public static void main(String[] args)\r\n    {\r\n        \r\n        SinglyLinkedList sllist = new SinglyLinkedList();\r\n  \r\n        sllist.head = new Node(1);\r\n        Node Node2 = new Node(2);\r\n        Node Node3 = new Node(3);\r\n  \r\n        sllist.head.next =Node2; \r\n        Node2.next = Node3; \r\n  \r\n        sllist.DisplayList();\r\n    }\r\n}<\/pre>\n<h3>Complexity of Linked List<\/h3>\n<p>Space complexity: O(n)<br \/>\nTime complexity:<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Operation<\/b><\/td>\n<td><b>Worst-case time complexity<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Search<\/span><\/td>\n<td><span style=\"font-weight: 400;\">O(n)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Insert<\/span><\/td>\n<td><span style=\"font-weight: 400;\">O(1)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Delete<\/span><\/td>\n<td><span style=\"font-weight: 400;\">O(1)<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Advantages of Linked List<\/h3>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Memory allocation takes place dynamically. A linked list can change the size, while an array has a fixed size.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Nodes in a linked list are non-contiguous stored, thus making efficient use of memory.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">No empty node can be present in a linked list.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Nodes are created randomly in the memory, therefore, space utilization is highly optimized.<\/span><\/li>\n<\/ol>\n<h3>Disadvantages of Linked List<\/h3>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Wastage of memory due to pointers.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Reverse traversing is not possible.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Accessing nodes at random is not possible.<\/span><\/li>\n<\/ol>\n<h3>Array vs Linked list<\/h3>\n<table>\n<tbody>\n<tr>\n<td><b>Array<\/b><\/td>\n<td><b>Linked List<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Random access of elements in an array is possible.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Random access of elements is not possible.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Elements in an array are in a contiguous memory location.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Elements in a linked list are at random in memory.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Memory allocation takes place at compile time.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Memory allocation takes place during runtime.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Array size is fixed.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The size of a linked list is variable. It can add or remove nodes as and when required.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Memory is allocated to the array in the stack section.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Memory is allocated to the linked list in the heap section.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Applications of Linked List<\/h3>\n<p><span style=\"font-weight: 400;\">1. Linked lists are used in programming requiring dynamic memory allocation.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">2. Advance scientific calculations and numerical analysis using sparse matrices. The sparse matrix is represented by a linked list.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">3. Linked list is useful for the implementation of stacks and queues.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">4. Also used in reversing the functionality of the software.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">5. Hash tables are created using linked lists. Hash table entries are implemented by a linked list.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">6. Graphs use linked lists. If you want to represent graphs as an adjacency list, we use linked lists.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">7. Polynomials can be represented with the help of linked lists. Each term in a polynomial has coefficient and power. Coefficient and power are stored as nodes and pointer points to the next node.<\/span><\/p>\n<h3>Conclusion<\/h3>\n<p><span style=\"font-weight: 400;\">After going through this article, we now have some basic understanding of linked lists, some real-life examples of linked lists, how linked lists work, and types of linked lists. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">We also learned some basic operations on a linked list like adding nodes, deleting nodes. We will learn about doubly linked lists and circular linked lists in future articles.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In computer science, we refer to the format of storing data on storage devices as a data structure. An array is the collection of data stored in contiguous memory locations. This makes accessibility very&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":95021,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24020],"tags":[24332,24331,24335,24334,24330,8301,24333,24337,24336],"class_list":["post-94985","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-structure-tutorials","tag-applications-of-linked-list","tag-data-structures","tag-delete-node-in-linked-list","tag-insert-node-in-linked-list","tag-linked-list","tag-linked-list-in-data-structure","tag-operations-on-linked-list","tag-reversing-a-linked-list","tag-traversing-a-linked-list"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Linked List in Data Structure - DataFlair<\/title>\n<meta name=\"description\" content=\"A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. Learn more about it.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linked List in Data Structure - DataFlair\" \/>\n<meta property=\"og:description\" content=\"A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. Learn more about it.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-21T03:30:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linked List in Data Structure - DataFlair","description":"A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. Learn more about it.","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:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/","og_locale":"en_US","og_type":"article","og_title":"Linked List in Data Structure - DataFlair","og_description":"A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. Learn more about it.","og_url":"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2021-05-21T03:30:04+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9"},"headline":"Linked List in Data Structure","datePublished":"2021-05-21T03:30:04+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/"},"wordCount":1462,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS.jpg","keywords":["Applications of linked list","Data Structures","Delete Node in Linked List","Insert node in Linked List","Linked List","linked list in Data Structure","Operations on Linked List","Reversing a Linked List","Traversing a Linked List"],"articleSection":["Data Structure Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/","url":"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/","name":"Linked List in Data Structure - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS.jpg","datePublished":"2021-05-21T03:30:04+00:00","description":"A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. Learn more about it.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/05\/Linked-list-in-DS.jpg","width":1200,"height":628,"caption":"Linked list in Data Structure"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/linked-list-in-data-structure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Data Structure Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/data-structure-tutorials\/"},{"@type":"ListItem","position":3,"name":"Linked List in Data Structure"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team is a group of passionate educators and industry experts dedicated to providing high-quality online learning resources on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. With years of experience in the field, the team aims to simplify complex topics and help learners advance their careers. At DataFlair, we believe in empowering students and professionals with the knowledge and skills needed to thrive in today\u2019s fast-paced tech industry. Follow us for Free courses, expert insights, tutorials, and practical tips to boost your learning journey.","url":"https:\/\/data-flair.training\/blogs\/author\/datafbdad\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/94985","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=94985"}],"version-history":[{"count":5,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/94985\/revisions"}],"predecessor-version":[{"id":95328,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/94985\/revisions\/95328"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/95021"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=94985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=94985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=94985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}