{"id":81068,"date":"2021-06-19T14:16:46","date_gmt":"2021-06-19T08:46:46","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=81068"},"modified":"2021-06-19T14:16:46","modified_gmt":"2021-06-19T08:46:46","slug":"doubly-linked-list","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/","title":{"rendered":"Doubly Linked List in Data Structure"},"content":{"rendered":"<p>Linked lists are a widely used data structure because of their wide range of applications. Linked lists are also of three types:<\/p>\n<p>1. Singly linked list<\/p>\n<p>2. Doubly linked list<\/p>\n<p>3. Circular linked list<\/p>\n<p>This article will cover doubly linked list in detail.<\/p>\n<h3>What is a doubly-linked list?<\/h3>\n<p>The singly linked list had a single pointer pointing to the next node. But a doubly linked list contains two pointers. One pointer points to the next node and one pointer to the previous node. Thus, a doubly linked list is a two-way chain.<\/p>\n<p>Every node in a doubly linked list has-<\/p>\n<ul>\n<li>Data<\/li>\n<li>Address of the next node<\/li>\n<li>Address of the previous node<\/li>\n<\/ul>\n<p>The purpose of a doubly linked list is to enable both-way traversal while still allowing non-contiguous memory storage. Just like a singly linked list, we need to have a starting pointer pointing to the first node. The last node in the list points to NULL.<\/p>\n<h3>Representation of Doubly Linked List<\/h3>\n<p>A doubly linked list is represented as follows:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81165\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image.jpg\" alt=\"Doubly linked list Representation\" width=\"1300\" height=\"350\" \/><\/a><\/p>\n<p>The above list is comprised of 4 nodes having four data points- A, B, C, D. Each node has two links one pointing forward and one pointing backwards.<\/p>\n<p>Each node has the following structure:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image02-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81173\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image02-1.jpg\" alt=\"Node structure\" width=\"450\" height=\"150\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>It comprises of two pointers and a data field.<\/p>\n<p><strong>a. Data<\/strong>: It constitutes the value of the data item inside the list.<\/p>\n<p><strong>b. Prev:<\/strong> It is a pointer pointing towards the previous node. For the first node, Prev points to NULL.<\/p>\n<p><strong>c. Next:<\/strong> It links the current node to the next node in the linked list. The \u2018Next\u2019 of the last node points towards NULL.<\/p>\n<h3>Basic Operations on Double Linked List<\/h3>\n<p>The basic set of operations that we can perform on a doubly linked list are:<\/p>\n<p><strong>1. Traverse forward:<\/strong> It means visiting each node from the beginning till the end with the help of the \u2018Next\u2019 pointer.<\/p>\n<p><strong>2. Traverse backwards:<\/strong> This operation is performed to visit each node but in the reverse direction. It will traverse the list from the end to the beginning.<\/p>\n<p><strong>3. Insertion:<\/strong> This operation inserts an element at any given position in the list.<\/p>\n<p><strong>4. Deletion<\/strong>: Deletion operation helps in deleting a node from the linked list.<\/p>\n<p><strong>5. Display forward:<\/strong> This operation is used to print\/display all the data elements of the linked list from beginning till the end.<\/p>\n<p><strong>6. Display backwards:<\/strong> it will display the elements from the end to the beginning.<\/p>\n<p><strong>7. Search:<\/strong> Search operation helps in searching an element by traversing it.<\/p>\n<h3>Memory Representation of Doubly Linked List<\/h3>\n<p>1. Each node in a doubly-linked list consists of 3 parts- two-pointers and a node.<\/p>\n<p>2. Due to two-pointers additional to data values, a doubly-linked list takes a lot of space as compared to other data structures.<\/p>\n<p>3. The following image shows the memory representation of a linked list.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image03.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81167\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image03.jpg\" alt=\"Memory Representation of Doubly Linked List:\" width=\"850\" height=\"850\" \/><\/a><\/p>\n<p>4. Here, -1 represents NULL.<\/p>\n<p>5. The Prev of the first node i.e. A and the Next of the last node i.e. D point towards NULL.<\/p>\n<p>6. This memory representation shows that the values need not be stored contiguously.<\/p>\n<p>7. The values 1000, 1056, 2004 and so on represent addresses in the memory.<\/p>\n<p>8. We traverse the list until we find -1 in the Next of a node.<\/p>\n<h3>Creating a Node in Doubly Linked List<\/h3>\n<p>Each node in a doubly linked list has data as well pointers. Therefore, we use a structure to create the node.<br \/>\nThe structure template for the node looks as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">struct Node\n{\n    int data;     \/\/The data point\n    struct Node *Prev;   \/\/Pointer to the previous node\n    struct Node *Next;    \/\/Pointer to the next node\n};\n<\/pre>\n<h3>Traversal in a Doubly Linked List<\/h3>\n<p>Traversal refers to linearly visiting each node. In a doubly linked list, we can traverse in both forward and backward directions.<\/p>\n<p>The function to perform the traversal is as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">List_traversal(struct Node *Head)\n{\n    Prev = (struct Node *)malloc(sizeof(struct Node));\n    Next = (struct Node *)malloc(sizeof(struct Node));\n    if(Head == NULL)   \/\/If the list is empty\n        return;\n    while(Next-&gt;data != NULL)\n    {\n        Print(Next-&gt;data);   \/\/The display operation\n        Next = Next-&gt;data;\n    }\n}\n<\/pre>\n<p>The time complexity for the traversal operation is O(n).<\/p>\n<h3>Doubly Linked List Methods<\/h3>\n<p>There are various inbuilt methods defined inside the doubly-linked list class. A few of these methods are:<\/p>\n<p><strong>1. add_front:<\/strong> This method adds a new node at the beginning of the doubly linked list.<\/p>\n<p><strong>2. add_after:<\/strong> It adds a new node after a particular node.<\/p>\n<p><strong>3. add_before:<\/strong> It is used to add a new node before a particular node in the list.<\/p>\n<p><strong>4. add_end:<\/strong> This method will add a new node at the end of the doubly linked list.<\/p>\n<p><strong>5. forward_traverse:<\/strong> It helps in traversing the list in the forward direction.<\/p>\n<p><strong>6. backward_traverse:<\/strong> It helps in traversing the list in the backward direction.<\/p>\n<p><strong>7. delete:<\/strong> This method deletes a node from the linked list.<\/p>\n<p>Their implementation inside the class is shown below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">class doubly_linked_list\n{\n  node *First;  \t\/\/ It points to the first node of the list\n  node *Last;   \t\/\/ It points to the last node of the list\n  \n  public:\n      Doubly_Linked_List()\n      {\n        front = NULL;\n        end = NULL;\n      }\n  void add_front(int );  \/\/Adds a new node at the beginning\n  void add_after(node* , int );   \/\/Adds a new node after the given node\n  void add_before(node* , int );  \/\/Adds a new node before a given node\n  void add_end(int );     \/\/Adds a new node at the end of the list\n  void delete_node(node*);    \/\/Ddeletes a particular node\n  void forward_traverse();    \/\/traverses the doubly-linked list in forward direction\n  void backward_traverse();   \/\/traverses the doubly-linked list in backward direction\n};\n<\/pre>\n<h3>Insertion in a Linked List<\/h3>\n<p>Insertion in a linked list occurs at three different positions:<\/p>\n<p>1. Insertion at the beginning of the list<\/p>\n<p>2. Insertion after a particular node.<\/p>\n<p>3. Insertion at the end of the list<\/p>\n<h4>Insertion at the beginning<\/h4>\n<p>We insert a node at the beginning such that the next pointer points to the node which was at first before. The previous pointer points to NULL.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image04.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81168\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image04.jpg\" alt=\"Insert at start in Doubly Linked List\" width=\"1400\" height=\"500\" \/><\/a><\/p>\n<p>Here, we have tried to insert M at the beginning.<\/p>\n<p>The pseudo-code for this operation will be:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Insertion_at_beginning(struct Node *Head, int key)\n{\n    Prev = (struct Node *)malloc(sizeof(struct Node));\n    Next = (struct Node *)malloc(sizeof(struct Node));\n    temp = (struct Node *)malloc(sizeof(struct Node));\n    if(Head == NULL)\n        return;\n    while(Next-&gt;data != NULL)\n    {\n        temp-&gt;data = key;\n        temp-&gt;Next = Head;\n        Head-&gt;Prev = temp;\n        Head = temp;\n        temp-&gt;Prev = NULL;\n    }\n}\n<\/pre>\n<p>Here, we will make use of an extra pointer \u2018temp\u2019 to perform the insertion operation.<\/p>\n<h4>Insertion at the End<\/h4>\n<p>If the list is empty, we will insert a node right after the Head. If the list is not empty, we first need to traverse the whole list to insert a node at the end of the list.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image05.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81169\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image05.jpg\" alt=\"Insertion at end in Doubly Linked List\" width=\"1400\" height=\"500\" \/><\/a><\/p>\n<p>In the above diagram, we are inserting M at the end.<\/p>\n<p>The function for insertion at the end is:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Insertion_at_end(struct Node *Head, int key)\n{\n    Ptr = (struct Node *) malloc(sizeof(struct node));  \n    Ptr-&gt;Next = NULL;  \n    Ptr-&gt;Prev=NULL;  \n    Ptr-&gt;data = key;  \n    Head = Ptr;  \n    Temp = head;   \n    while (temp != NULL)  \n        temp = temp -&gt; next;   \n    temp-&gt;Next = Ptr;   \n    Ptr-&gt;Prev = temp;   \n    Ptr-&gt;Next = NULL;   \n}\n<\/pre>\n<h4>Insertion after a particular node<\/h4>\n<p>Insertion after a particular node involves traversing all nodes before that node. We will make use of an extra pointer \u2018temp\u2019 for traversing the node up to a particular position.<\/p>\n<p>For example, suppose we wish to insert a node having data value \u2018M\u2019 between node \u2018B\u2019 and node \u2018C\u2019, we will do it as follows:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image06.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81170\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image06.jpg\" alt=\"Insert at particular position in Linked List\" width=\"1350\" height=\"400\" \/><\/a><\/p>\n<p>The function will be:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Insert_after_particular_position(struct Node *Head, int key)\n{\n    Ptr = (struct Node *) malloc(sizeof(struct node));  \/\/Allocating memory for the new node\n    temp = Head;  \n    Ptr-&gt;data = key;\n    for(i=0; i&lt;position; i++)  \n   {  \n       temp = temp-&gt;Next;  \n       if(temp == NULL) \/\/ i.e. if the list is empty   \n             return;  \n   }\n   Ptr-&gt;Next = temp-&gt;Next;   \n   Ptr-&gt;Prev = temp;   \n   temp-&gt;Next = Ptr;   \n   temp-&gt;Next-&gt;Prev = Ptr;    \n}\n<\/pre>\n<h3><span style=\"font-weight: 400\">Time complexity of Insertion:<\/span><\/h3>\n<table>\n<tbody>\n<tr>\n<td><b>Insertion operation<\/b><\/td>\n<td><b>Complexity\u00a0<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">At the beginning<\/span><\/td>\n<td><span style=\"font-weight: 400\">O(1)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">After a particular node<\/span><\/td>\n<td><span style=\"font-weight: 400\">O(1)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">At the end<\/span><\/td>\n<td><span style=\"font-weight: 400\">O(n)<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Deletion from a Linked List:<\/h3>\n<p>Deletion involves deleting nodes from the list. It also works in three different cases:<\/p>\n<p>1. Deletion from beginning<\/p>\n<p>2. Deletion at the end<\/p>\n<p>3. Deleting a node other than the first and the last node<\/p>\n<h4>1. Deletion from the beginning:<\/h4>\n<p>It involves deleting the first node of the doubly linked list. The following diagram shows the deletion operation at the beginning of the doubly linked list.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image07.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81171\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image07.jpg\" alt=\"Deletion in doubly linked List\" width=\"1350\" height=\"400\" \/><\/a><\/p>\n<p>The deletion function will be:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Deletion_from_beginning(int key){\n    struct Node *Ptr = Head;  \n    if (Head == NULL) return;\n    Head = Head-&gt;Next;\n    Head-&gt;Prev = NULL;\n    free(Ptr);\n}\n<\/pre>\n<p>The free function is used to release the memory space. If we don\u2019t release memory after using it, it might lead to memory leakage problems in future.<\/p>\n<h4>2. Deletion at the end:<\/h4>\n<p>If the list is empty, we will directly pass the return statement in the function. If the list contains a single node, we just need to make the Head point towards NULL. When the list has two or more nodes, we need to traverse the whole node and then delete the last node.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image08-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81177\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image08-1.jpg\" alt=\"Delete at the end in Doubly Linked List\" width=\"1350\" height=\"400\" \/><\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Deletion_at_end(int key){\n    struct Node *Ptr = Head;  \n    if(Head == NULL)  \/\/If the list is empty\n        return;\n    if(Ptr-&gt;Next == NULL)  \/\/If the list has only one element\n    {\n        Head-&gt;Next = NULL;\n        return;\n    }\n    Ptr-&gt;Prev-&gt;Next = NULL;\n    free(ptr);\n}\n<\/pre>\n<h4>Deletion after a particular node:<\/h4>\n<p>If we know the address of a particular node, we can easily delete the node next to it.<br \/>\nFor example, suppose we wish to delete node \u2018C\u2019 from the list having nodes: \u2018A\u2019, \u2018B\u2019, \u2018C\u2019 and \u2018D\u2019. Then, we will do it as follows:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image09.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81174\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image09.jpg\" alt=\"Deletion from Doubly Linked List\" width=\"1350\" height=\"400\" \/><\/a><\/p>\n<p>The function will be:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Deletion_after_particular_node(int key){\n    struct Node *temp = Head;  \n    if(Head == NULL)  \/\/If the list is empty\n        return;\n    if(temp -&gt; Next == NULL)  \/\/If the list has only 1 node \n        return;   \n    while(temp-&gt;data != key)  \/\/Traversing the list   \n        temp = temp-&gt;Next; \n    if(temp-&gt;Next-&gt;Next == NULL)  \/\/If the node to be deleted is the last node\n        temp-&gt;Next = NULL;  \n    Ptr = temp-&gt;Next;  \n    temp-&gt;Next = Ptr-&gt;Next;  \n    Ptr-&gt;Next-&gt;Prev = temp;  \n    free(ptr);\n}\n<\/pre>\n<h3><span style=\"font-weight: 400\">Time complexity for Deletion operation:<\/span><\/h3>\n<table>\n<tbody>\n<tr>\n<td><b>Deletion operation<\/b><\/td>\n<td><b>Complexity\u00a0<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">At the beginning<\/span><\/td>\n<td><span style=\"font-weight: 400\">O(1)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">After a particular node<\/span><\/td>\n<td><span style=\"font-weight: 400\">O(n)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">At the end<\/span><\/td>\n<td><span style=\"font-weight: 400\">O(n)<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Doubly Linked List as Circular Linked list:<\/h3>\n<p>A doubly linked list contains pointers to both the previous and the next node. A circular list does not contain any NULL pointer. In a circular linked list, the \u2018Next\u2019 of the last nodes points to the first node of the list.<\/p>\n<p>Combination of a doubly list and a circular list is known as a doubly-circular list. A doubly-circular linked list looks as follows:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image10.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81175\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/TechVidvan-Doubly-linked-list-normla-image10.jpg\" alt=\"Doubly Linked List as Circular Linked list\" width=\"1350\" height=\"400\" \/><\/a><\/p>\n<p>1. The \u2018Next\u2019 pointer of the last node in the doubly-linked list points to the points to the first node in the list.<\/p>\n<p>2. The \u2018Prev\u2019 pointer of the first node points to the last node of the linked list.<\/p>\n<p>3. There is no NULL pointer anywhere in the list.<\/p>\n<h3>Advantages of a Doubly Linked List:<\/h3>\n<p>1. We can traverse a doubly linked list in both forward and backward direction.<\/p>\n<p>2. Traversal in the backward direction makes the deletion operation more efficient. If the pointer to a node is given, we can easily delete the previous node with O\u2019s time complexity O(1).<\/p>\n<p>3. The insertion operation is also more efficient. If the pointer a node is given, we can easily insert a node before that node.<\/p>\n<h3>Disadvantages of a Doubly Linked List:<\/h3>\n<p>1. A doubly linked list takes more space than a singly list because of the presence of an extra \u2018Prev\u2019 pointer at each node.<\/p>\n<p>2. We need to maintain this extra \u2018Prev\u2019 pointer while performing all the operations. This increases the space complexity of all the operations performed on a doubly linked list.<\/p>\n<h3>Conclusion<\/h3>\n<p>The crux of this article is that a doubly linked list has a similar behaviour as a singly list most of the time. However, there are a few cases when a double list performs better than a singly linked list. Insertion and deletion operations are easier and more efficient in a doubly-linked list as compared to a singly linked list. But they are easier at the cost of additional space for the program.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linked lists are a widely used data structure because of their wide range of applications. Linked lists are also of three types: 1. Singly linked list 2. Doubly linked list 3. Circular linked list&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":81164,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3555],"tags":[3563,3564,3565,3566,3567],"class_list":["post-81068","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-structure","tag-deletion-in-doubly-linked-list","tag-doubly-linked-list","tag-doubly-linked-list-in-data-structure","tag-insertion-in-doubly-linked-list","tag-traversing-in-doubly-linked-list"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Doubly Linked List in Data Structure - TechVidvan<\/title>\n<meta name=\"description\" content=\"Learn about Doubly Linked List (contains two pointers), Basic operations, Time complexity, its Memory Representation, advantages, limitations\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Doubly Linked List in Data Structure - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Learn about Doubly Linked List (contains two pointers), Basic operations, Time complexity, its Memory Representation, advantages, limitations\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-19T08:46:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Doubly-linked-list-in-DS-1.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=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan 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":"Doubly Linked List in Data Structure - TechVidvan","description":"Learn about Doubly Linked List (contains two pointers), Basic operations, Time complexity, its Memory Representation, advantages, limitations","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:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/","og_locale":"en_US","og_type":"article","og_title":"Doubly Linked List in Data Structure - TechVidvan","og_description":"Learn about Doubly Linked List (contains two pointers), Basic operations, Time complexity, its Memory Representation, advantages, limitations","og_url":"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-06-19T08:46:46+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Doubly-linked-list-in-DS-1.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Doubly Linked List in Data Structure","datePublished":"2021-06-19T08:46:46+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/"},"wordCount":1528,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Doubly-linked-list-in-DS-1.jpg","keywords":["Deletion in Doubly Linked List","Doubly linked list","Doubly Linked List in Data Structure","Insertion in Doubly Linked List","Traversing in Doubly Linked List"],"articleSection":["Data Structure Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/","url":"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/","name":"Doubly Linked List in Data Structure - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Doubly-linked-list-in-DS-1.jpg","datePublished":"2021-06-19T08:46:46+00:00","description":"Learn about Doubly Linked List (contains two pointers), Basic operations, Time complexity, its Memory Representation, advantages, limitations","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Doubly-linked-list-in-DS-1.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Doubly-linked-list-in-DS-1.jpg","width":1200,"height":628,"caption":"Doubly linked list in DS"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/doubly-linked-list\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Doubly Linked List in Data Structure"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/81068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=81068"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/81068\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/81164"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=81068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=81068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=81068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}