{"id":31899,"date":"2021-04-20T21:46:32","date_gmt":"2021-04-20T16:16:32","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/"},"modified":"2024-11-13T16:21:54","modified_gmt":"2024-11-13T10:51:54","slug":"link-in-c","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/","title":{"rendered":"LINKED LIST IN C++"},"content":{"rendered":"\n<p><strong>INTRODUCTION -<\/strong>It is a sequence of items (objects) where every item is linked to the next. They are linked to one another through pointers. There are two parts in each node: the first part contains the data, and the second part contains the address of the next node in the linked list. Address part of the node which is connected to next is also called a link. The following Fig. 1. shows a typical example of a node.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/5Xu103aKo1LPSUJ7mJMenaTZzwcXt8QSumw68K9aZsMZvgq4K0N878g0f_MnxuLxt3IKm4ZLaVW4AdX4OSm1ZImaggb47ipfHeUzWJTIu1k-c80yW2iwYlq0fYeAsLt1DOzI9Pc\" alt=\"\"\/><figcaption class=\"wp-element-caption\"><strong>Fig. 1. Linked List<\/strong><\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/qQSpjtbFA75wuzvCOgICnjgdNnDYHPgl62xeeR60ZRiEso3mWb6bh9YVzKeYtcYGJreErT_zMuvhKylowcWI6wkbpxJQMcwAlQWF41kqGjd5NCX04Rt0o5HTQq1rj-1zEufF6wg\" alt=\"\"\/><figcaption class=\"wp-element-caption\"><strong>Fig. 2. Linked List representation in Memory<\/strong><\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Fig. 2. shows a schematic diagram of a linked list. Each node is pictured with two parts. The left part of each node contains the data, and the right part represents the address of the next node. There is an arrow that shows that the first node is connected to the next node.&nbsp;<\/p>\n\n\n\n<p><strong>IMPLEMENTATION OF LINKED LIST<\/strong><\/p>\n\n\n\n<p>When we say linked list, we are talking about a singly linked list. There are various types of linked lists which we will discuss below, but here we are going to implement a singly linked list. There is a concept of pointer and structure, what structure data type is in C++ language, also, how to access the structure members using that structure variable and pointer.<\/p>\n\n\n\n<p>First of all, see the logical view of a linked list in Fig. 3, which shows the linked list having three nodes.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/SVjRc2gwbLvYli_ZQRn0507H6ukSiyijIp-bJm8rUlAQknUKEtMUXLfAkVKRaZtC35827ONAhcM0zubO3DfUUjEJa1Qb3j7O_ZtjWBLApvkHXEkzrPuCLv5ovQ8THr64gx2SnbA\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Fig 3<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>First, we have to create a node.&nbsp;<\/p>\n\n\n\n<p><strong>Creating a node using a user-defined data type, i.e. structure :<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/6x1zBcgvt_sAfpmXy5RfXGDmSk5MzK55gf2Gwmj1msotAF7xdlsT5F81dj0id3s6QRif347uAdaa9MmqyCFMKJ2g1Ym3PT42fLn1_31B12v4SRDBPUXbEROkIAjD41Dc_OSOYto\" alt=\"\"\/><\/figure>\n\n\n\n<p>Also Read: <a href=\"https:\/\/www.mygreatlearning.com\/blog\/function-overloading-in-cpp\/\">Function overloading in C++<\/a><\/p>\n\n\n\n<p><strong>TYPES OF LINKED LIST<\/strong><\/p>\n\n\n\n<p>&nbsp;We can divide the linked list into the following three types mainly:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Singly-linked list<\/li>\n\n\n\n<li>Doubly linked list<\/li>\n\n\n\n<li>Circular linked list<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Singly Linked List or One-Way Chain<\/strong><\/li>\n<\/ol>\n\n\n\n<p>In a singly linked list, all the nodes are arranged sequentially. A node in the singly linked list consists of two parts: the data part and the link\/address part. The data part of the node stores actual information that is to be represented by the node, while the link or the address part of the node stores the address of its immediate successor.<\/p>\n\n\n\n<p>A one-way chain or singly linked list can be traversed in one direction only; that is why it is known as a one-way chain. Fig. 4. shows the linked list.&nbsp;&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/lnZLQhpoeVeZqs9-BmPSwXv0hWRF3jkt6rcCuSAlEXw7uUZ0eiO8zaHO3WVBHVWTuPVoGoXLhcd87e3JjfGaS7nr5xysixusyIE1TO0pAsc4vOrhNJky5ckOuT9_lfT1EdgclRE\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Fig 4<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/fxPlv0AsDU7gX1vAJy-Mn7O_TPojGEVgArGhBWxWgYPaY9mYECft5M1Zbkg1dwmvb57Vw51bn0Adfb9EkNC21bRxXUiAlh5oolLjI92xJVHCUvxv3VSC2s0xGe8C7qZzPJ_IkEQ\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/Y97UOwVtp1X3U0ZsjF3_EWCvVQpIooz-QavOg7zrRA9g_V37wRn5eK_fnhzFlPapxXKJ2u0EktKWZJUt6NrPZeLEbI3WkCuVY9tyB-BhJ26XlJiTSZFAaKKDYWMlYBPBHKu5UN4\" alt=\"\"\/><\/figure>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Doubly Linked List<\/strong><\/li>\n<\/ol>\n\n\n\n<p>In a singly linked list, as each node contains the next node\u2019s address, it doesn't have any record of its previous node. However, a doubly-linked list will apply in place of a singly linked list. As we also know, each node of the list contains the address of its previous node of the linked list, so we can find all the details about the previous node by using the previous address stored inside the previous part of each node in a linked list.<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;Every node in the doubly linked list has three fields that are Left_Pointer, Right_Pointer and Data. Fig.5 shows a doubly linked list.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/l3YTW384rgaojoXE1emOvFxQtDSBEoLjxVcZhl_0rgWBe_-9VY-1oWWXwV_sjYIo3E978ljqBlKmwgbgcTxsG9NEpbqo2mmh7wAhbBFYzwV3pQcbNfpG_p4m1vju7mvp1Ht1O7M\" alt=\"\"\/><\/figure>\n\n\n\n<p>the point will point to the node on the left side (or previous node) that will hold the previous node\u2019s address in a doubly-linked list. RPoint will point the right side (or next node) to the next node\u2019s address in a linked list. Data will store the information of the node.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/jJvfXF5phVmKX3igbensg8sUS3kHrdP1Mp3-SXGqqE7-ir7qJhacTaCxGjC3q_0iNKME67GYHU9TAG_ePWLA15TzYvEv9fxjW9JPAZ_S8TDsc0m8MwkHKCWhHV6iAivzTdbE0J8\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Representation of Doubly Linked List<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/l8hN658CdRZELGVcBK2m5Tk_JZXAN-zFYkV9f7f7dqSPj1DCNrmjBtJVAtRWlW95clpAQWWOqO2QbtUyW3zN59SgbLN_JJRE4XaMEREd1xGDaToUlvr3ltvhXMlWA2zJCyI6IwA\" alt=\"\"\/><\/figure>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Circular Linked List<\/strong><\/li>\n<\/ol>\n\n\n\n<p>A circular linked list is one where there is no beginning and no end. A singly linked list can be made a circular linked list by simply storing the address of the first node in the linked field of the last node in a linked list. A circular linked list is shown in Fig. 6<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/IUvdu9b3cA29nCXO51Wm3_5nlvjmqr1_f5EuanpkS2IE2mUR1Cd7jTuPNv1VhAYe8bP3rMXi4viJUpjJaQJrTZnuC-9nQZPtZKHX1DRdR8-F4BgesnHAjsgBFfDAu5pQunxsx0k\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/LpIxN72A4qYqj0iifuMHRZrBqA8fHIh4aGhxf2ncEvr9cIrcv33xL74ZQEkphzK6b-4A4p72N0r5rSIMO-WGCn1q3unC8KVHyq2m4hMgJaFXIIoA3LWQqlZd51qMMtrUtNxA8zI\" alt=\"\"\/><\/figure>\n\n\n\n<p>We can traverse a circular linked list until we reach the same node from where we started.<\/p>\n\n\n\n<p>There is no null value present in any of the nodes in a circular linked list.<\/p>\n\n\n\n<p><strong>OPERATIONS ON LINKED LIST<\/strong><\/p>\n\n\n\n<p>The operations performed on the Linked List are as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Creation<\/li>\n\n\n\n<li>Insertion&nbsp;<\/li>\n\n\n\n<li>Deletion&nbsp;<\/li>\n\n\n\n<li>Traversing<\/li>\n\n\n\n<li>Searching&nbsp;<\/li>\n\n\n\n<li>Concatenation<\/li>\n<\/ol>\n\n\n\n<p><strong><em>Creation<\/em><\/strong> operation is used to create a node or linked list. When a linked list is created with one node, an insertion operation is used to add more elements to the node.<\/p>\n\n\n\n<p><strong><em>Insertion <\/em><\/strong>operation is used to insert a new node at any location in the linked list. A new node may be inserted:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>At the beginning of the linked list<\/li>\n\n\n\n<li>At the end of the linked list<\/li>\n\n\n\n<li>At any position in a linked list<\/li>\n<\/ol>\n\n\n\n<p><strong><em>Deletion <\/em><\/strong>operation is used to delete or remove a node from the linked list. A node may be deleted from the<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Beginning of a linked list&nbsp;<\/li>\n\n\n\n<li>End of a linked list<\/li>\n\n\n\n<li>Specified location of the linked list<\/li>\n<\/ol>\n\n\n\n<p><strong><em>Traversing<\/em><\/strong><em> <\/em>is the process of going through each node from one end to another end of a linked list. In a singly linked list, we can visit from left to right, forward traversing, but we can not go from right to left. In a doubly-linked list, both side traversing is possible.<\/p>\n\n\n\n<p><strong><em>Concatenation <\/em><\/strong>is the process of appending the second list to the end of the first list in a linked list. Let us consider a list A having n nodes and B with m nodes. Then the concatenation will place the 1<sup>st<\/sup> node of B in the (n+1)th node in list A. After concatenation, A will contain (n+m) nodes in the list.<\/p>\n\n\n\n<p><strong>EXAMPLES:<\/strong><\/p>\n\n\n\n<p><strong>OPERATIONS ON SINGLY LINKED LIST<\/strong><\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Some operations can be performed on a singly linked list. A list of all the operations is &nbsp; given below.<\/p>\n\n\n\n<p><strong>Node Creation<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/tGQzCLQmsPb3pLoYM3fDZqpfavHHjglz_pADA0DYA1UfWxsKmEvY4JDD61ohlLe5m9mi1R44wYmxha_Pn2-R0LIf1_K3Jg-NXsuK-8NdTJTl674ZgiUb8dola_VtdroK52-vx7Y\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>INSERTION&nbsp;<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Insertion in a singly linked list<\/strong>:&nbsp;<\/li>\n<\/ol>\n\n\n\n<p>There are the following steps to insert a new node in the list.&nbsp;<\/p>\n\n\n\n<p>\u2022 Allocate the space for the new node and store data into the data part of the node in the singly linked list.&nbsp;<\/p>\n\n\n\n<p>\u2022 ptr = (struct node *) malloc(sizeof(struct node *)); o ptr \u2192 data = item&nbsp;<\/p>\n\n\n\n<p>\u2022 Now, link part of the new node pointing to the first node of the list.&nbsp;<\/p>\n\n\n\n<p>&nbsp;\u2022 ptr-&gt;next = head;&nbsp;<\/p>\n\n\n\n<p>\u2022 Now, at last, we need to make the new node the first node of the list&nbsp;<\/p>\n\n\n\n<p>&nbsp;\u2022 head = ptr;&nbsp;<\/p>\n\n\n\n<p><strong>Algorithm&nbsp;<\/strong><\/p>\n\n\n\n<p>STEP-1: IF PTR = NULL&nbsp;<\/p>\n\n\n\n<p>Write OVERFLOW<\/p>\n\n\n\n<p>&nbsp;Go to STEP-7<\/p>\n\n\n\n<p>ELSE<\/p>\n\n\n\n<p>STEP-2: SET NEW_NODE = PTR&nbsp;<\/p>\n\n\n\n<p>STEP-3: SET PTR = PTR \u2192 NEXT&nbsp;<\/p>\n\n\n\n<p>STEP-4: SET NEW_NODE \u2192 DATA = VAL&nbsp;<\/p>\n\n\n\n<p>STEP-5: SET NEW_NODE \u2192 NEXT = HEAD<\/p>\n\n\n\n<p>&nbsp;STEP-6: SET HEAD = NEW_NODE&nbsp;<\/p>\n\n\n\n<p>STEP-7: EXIT<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/HN_Fc2gDEUiExFtelT9zAhYPm45sRmUnVRhmTw2kjQq1gmN1egSorlFCxlpCou3U5tGrWcpgnR9EfJgjWfJyFCrwLvIihy1qYAlyawQlwj5MmnAtavW0Goi9geI_Ghe7j5UY_Uc\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>DELETION&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>Deletion in a singly linked list:<\/strong><\/p>\n\n\n\n<p>Deleting a node from the beginning of the list is the simplest operation of all the operations. Since the first node of the list is to be deleted, we have to make the head and point to the next of the head.<\/p>\n\n\n\n<p>&nbsp;\u2022 ptr = head;<\/p>\n\n\n\n<p>&nbsp;\u2022 head = ptr-&gt;next;&nbsp;<\/p>\n\n\n\n<p>&nbsp;\u2022 The pointer ptr pointing to the head node is now free.&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;\u2022 free(ptr)<\/p>\n\n\n\n<p><strong>Algorithm&nbsp;<\/strong><\/p>\n\n\n\n<p>STEP-1: IF HEAD = NULL<\/p>\n\n\n\n<p>&nbsp;Write UNDERFLOW<\/p>\n\n\n\n<p>&nbsp;Go to STEP-5 [END OF IF]&nbsp;<\/p>\n\n\n\n<p>STEP-2: SET PTR = HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-3: SET HEAD = HEAD -&gt; NEXT&nbsp;<\/p>\n\n\n\n<p>STEP-4: FREE PTR&nbsp;<\/p>\n\n\n\n<p>STEP-5: EXIT<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/Rp0CA5k_n-59_JxuJgv7lpB5GZPmmZpNFjdV2rVeKRSCvXp8db-K28VazNd0VlSPvwrv8SEQZHvrqhymoG77ItsqQGSoUy9QzAkcxXFFzjlCKeyiNwwqrBuOOu1RrxD_MbkQIpA\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/6SkVRf-xr_bRGEzRjNBZKAgqQUWWCCHcKZ3YTYyzsC-asrDBTh5wyHYjL05pVe5nfU5wf8LKTMxVEbKksKkWfaeggsiJQRnW9Vt5iGT3KbrW_iuVsqodcCfVZipj3GSl_gvHoGw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Traversing in a singly linked list&nbsp;<\/strong><\/p>\n\n\n\n<p>Traversing means visiting each node of the list when we perform operations on that.&nbsp;<\/p>\n\n\n\n<p>&nbsp;ptr = head;<\/p>\n\n\n\n<p>&nbsp;while (ptr!=NULL)<\/p>\n\n\n\n<p>&nbsp;{<\/p>\n\n\n\n<p>&nbsp;ptr = ptr -&gt; next;<\/p>\n\n\n\n<p>&nbsp;}<\/p>\n\n\n\n<p>&nbsp;<strong>Algorithm<\/strong><\/p>\n\n\n\n<p>&nbsp;STEP-1: SET PTR = HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-2: IF PTR = NULL&nbsp;<\/p>\n\n\n\n<p>WRITE \"EMPTY LIST\"&nbsp;<\/p>\n\n\n\n<p>GOTO STEP-7&nbsp;<\/p>\n\n\n\n<p>END OF IF&nbsp;<\/p>\n\n\n\n<p>STEP-4: REPEAT STEP-5 AND 6 UNTIL PTR == NULL&nbsp;<\/p>\n\n\n\n<p>STEP-5: PRINT PTR\u2192 DATA&nbsp;<\/p>\n\n\n\n<p>STEP-6: PTR = PTR \u2192 NEXT&nbsp;<\/p>\n\n\n\n<p>[END OF LOOP]&nbsp;<\/p>\n\n\n\n<p>STEP-7: EXIT<\/p>\n\n\n\n<p><strong>Searching in a singly linked list&nbsp;<\/strong><\/p>\n\n\n\n<p>Searching is used to find the location of a particular item in the list. The searching operation needs traversing through the list.&nbsp;<\/p>\n\n\n\n<p><strong>Algorithm<\/strong><\/p>\n\n\n\n<p>&nbsp;STEP-1: SET PTR = HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-2: Set I = 0&nbsp;<\/p>\n\n\n\n<p>STEP-3: IF PTR = NULL&nbsp;<\/p>\n\n\n\n<p>WRITE \"EMPTY LIST\"&nbsp;<\/p>\n\n\n\n<p>GOTO STEP-8&nbsp;<\/p>\n\n\n\n<p>END OF IF&nbsp;<\/p>\n\n\n\n<p>STEP-4: REPEAT STEP-5 TO 7 UNTIL PTR == NULL&nbsp;<\/p>\n\n\n\n<p>STEP-5: if ptr \u2192 data = item write i+1 End of IF&nbsp;<\/p>\n\n\n\n<p>STEP-6: I = I + 1&nbsp;<\/p>\n\n\n\n<p>STEP-7: PTR = PTR \u2192 NEXT&nbsp;<\/p>\n\n\n\n<p>[END OF LOOP]&nbsp;<\/p>\n\n\n\n<p>STEP-8: EXIT<\/p>\n\n\n\n<p><strong>OPERATIONS ON DOUBLY LINKED LIST:<\/strong><\/p>\n\n\n\n<p><strong>Node Creation<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/zrWHQIIKL28npmPm8986vtGDJe_5opn1ssafypid7YakARv-MYKjP_q8rTdLkMMbGBEv1gjmt8T_iiET0JQy5n9qJBcqBdiAjp3jVi6EbF887P-sFbz0GWzA6HJBaA0M_sSPdtA\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>INSERTION<\/strong><\/p>\n\n\n\n<p><strong>Insertion in a doubly-linked list:<\/strong><\/p>\n\n\n\n<p>&nbsp;In the doubly linked list, each node of the list contains double pointers.<\/p>\n\n\n\n<p><strong>Algorithm<\/strong><\/p>\n\n\n\n<p><strong>STEP-1: <\/strong>IF ptr = NULL Write OVERFLOW<\/p>\n\n\n\n<p>Go to STEP-9 [END OF IF]<\/p>\n\n\n\n<p><strong>STEP-2: <\/strong>SET NEW_NODE = ptr<\/p>\n\n\n\n<p><strong>STEP-3: <\/strong>SET ptr = ptr -&gt; NEXT<\/p>\n\n\n\n<p><strong>STEP-4: <\/strong>SET NEW_NODE -&gt; DATA = VAL<\/p>\n\n\n\n<p><strong>STEP-5: <\/strong>SET NEW_NODE -&gt; PREV = NULL <strong>STEP-6: <\/strong>SET NEW_NODE -&gt; NEXT = START <strong>STEP-7: <\/strong>SET head -&gt; PREV = NEW_NODE<\/p>\n\n\n\n<p><strong>STEP-8: <\/strong>SET head = NEW_NODE<\/p>\n\n\n\n<p><strong>STEP-9: <\/strong>EXIT<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/0vqkNJB4iP-2LIJnTlusrdLgKZK-h2sKQwN8Y0FdRldDX4-GyKca4SaSp5AXYt26B_v16_MrcbACZ1nYQD0VoPsbEuD4ZrrD-DUyx8TIXvKE8jbjLnJg3TacCbnVJLjabN8pl8s\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>DELETION<\/strong><\/p>\n\n\n\n<p><strong>Deletion in a doubly-linked list<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>For deletion in doubly linked lists, we have to copy the head pointer to pointer ptr. We also have to shift the head pointer to its next.\n<ul class=\"wp-block-list\">\n<li>Ptr = head;<\/li>\n\n\n\n<li>head = head \u2192 next;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>now make the prev of this new head node point to NULL(prev=NULL).\n<ul class=\"wp-block-list\">\n<li>head \u2192 prev = NULL<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>Algorithm&nbsp;<\/strong><\/p>\n\n\n\n<p>STEP-1: IF HEAD = NULL&nbsp;<\/p>\n\n\n\n<p>WRITE UNDERFLOW&nbsp;<\/p>\n\n\n\n<p>GOTO STEP-6&nbsp;<\/p>\n\n\n\n<p>STEP-2: SET PTR = HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-3: SET HEAD = HEAD \u2192 NEXT&nbsp;<\/p>\n\n\n\n<p>STEP-4: SET HEAD \u2192 PREV = NULL&nbsp;<\/p>\n\n\n\n<p>STEP-5: FREE PTR&nbsp;<\/p>\n\n\n\n<p>STEP-6: EXIT<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/JjoBxTH6UdYpcthgROF7L84-mFunjIFZ6soSHfSH3rQHudAOMYPLhIRO7yNxhaPQhXwbPWqEwdiwVXjHNxYbw_PtnDoiGoX-Qf7fJvY0asrn3F0nJj3GrQObijFPpYDSdQZevZk\" width=\"602\" height=\"152\"><\/h1>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"traversing-in-a-doubly-linked-list\"><strong>Traversing in a doubly-linked list<\/strong><\/h1>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Copy the head pointer in any of the temporary pointers, here we will be using ptr.\n<ul class=\"wp-block-list\">\n<li>Ptr = head<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>then traverse through the list. Keep shifting the value of the pointer variable <strong>ptr<\/strong><\/li>\n<\/ul>\n\n\n\n<p>until we find the last node of the list. The last node contains <strong>null<\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>while(ptr != NULL)<\/li>\n\n\n\n<li>{\n<ul class=\"wp-block-list\">\n<li>printf(\"%dn\",ptr-&gt;data);<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>ptr=ptr-&gt;next;<\/li>\n\n\n\n<li>}<\/li>\n<\/ul>\n\n\n\n<p><strong>Algorithm&nbsp;<\/strong><\/p>\n\n\n\n<p>STEP-1: IF HEAD == NULL&nbsp;<\/p>\n\n\n\n<p>WRITE \"UNDERFLOW\"&nbsp;<\/p>\n\n\n\n<p>GOTO STEP-6&nbsp;<\/p>\n\n\n\n<p>[END OF IF]&nbsp;<\/p>\n\n\n\n<p>STEP-2: Set PTR = HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-3: Repeat STEP-4 and 5 while (PTR == NULL)&nbsp;<\/p>\n\n\n\n<p>STEP-4: Write PTR \u2192 data&nbsp;<\/p>\n\n\n\n<p>STEP-5: PTR = PTR \u2192 next&nbsp;<\/p>\n\n\n\n<p>STEP-6: Exit<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"searching-in-doubly-linked-list\"><strong>Searching in Doubly Linked List<\/strong><\/h1>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Copy head pointer into a temporary pointer variable, here we use ptr.\n<ul class=\"wp-block-list\">\n<li>ptr = head<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>declare a local variable I for assigning its value as 0.\n<ul class=\"wp-block-list\">\n<li>i=0<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Traverse the list until the pointer becomes null(ptr==NULL). Keep shifting pointer to its next and increasing I by +1.<\/li>\n\n\n\n<li>Compare each element of the list with the other items which are to be searched.<\/li>\n<\/ul>\n\n\n\n<p><strong>Algorithm&nbsp;<\/strong><\/p>\n\n\n\n<p>STEP-1: IF HEAD == NULL&nbsp;<\/p>\n\n\n\n<p>WRITE \"UNDERFLOW\"&nbsp;<\/p>\n\n\n\n<p>GOTO STEP-8&nbsp;<\/p>\n\n\n\n<p>[END OF IF]&nbsp;<\/p>\n\n\n\n<p>STEP-2: Set PTR = HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-3: Set i = 0&nbsp;<\/p>\n\n\n\n<p>STEP-4: Repeat STEP-5 to 7 while (PTR == NULL)&nbsp;<\/p>\n\n\n\n<p>STEP-5: IF PTR \u2192 data = item return i&nbsp;<\/p>\n\n\n\n<p>[END OF IF]&nbsp;<\/p>\n\n\n\n<p>STEP-6: i = i + 1&nbsp;<\/p>\n\n\n\n<p>STEP-7: PTR = PTR \u2192 next<\/p>\n\n\n\n<p>&nbsp;STEP-8: Exit<\/p>\n\n\n\n<p><strong>OPERATION ON CIRCULAR SINGLY LINKED LIST:<\/strong><\/p>\n\n\n\n<p><strong>INSERTION<\/strong><\/p>\n\n\n\n<p><strong>Insertion into the circular singly linked list:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In the first case, the condition <strong>head == NULL <\/strong>will be true. Since we know that, we are inserting the node is a circular singly linked list, so the node of the list will point to itself only.\n<ul class=\"wp-block-list\">\n<li>if(head == NULL)<\/li>\n\n\n\n<li>{\n<ul class=\"wp-block-list\">\n<li>head = ptr;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>ptr -&gt; next = head;<\/li>\n\n\n\n<li>}<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>The condition head == NULL will become false, this means that there is at least one node in the list. Here, we have to traverse the list for reaching that point.\n<ul class=\"wp-block-list\">\n<li>temp = head;<\/li>\n\n\n\n<li>while(temp-&gt;next != head)\n<ul class=\"wp-block-list\">\n<li>temp = temp-&gt;next;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>We have to make the next pointer of the last node point to the head node of the list.\n<ul class=\"wp-block-list\">\n<li>temp -&gt; next = ptr;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>the next pointer of temp will point to the existing head node of the list.\n<ul class=\"wp-block-list\">\n<li>ptr-&gt;next = head;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Make the new node ptr, which is a new head node of the circular singly linked list.\n<ul class=\"wp-block-list\">\n<li>head = ptr;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>In this way, we inserted the node ptr into the circular singly linked list.<\/li>\n<\/ul>\n\n\n\n<p><strong>Algorithm&nbsp;<\/strong><\/p>\n\n\n\n<p>STEP-1: IF PTR = NULL<\/p>\n\n\n\n<p>&nbsp;Write OVERFLOW&nbsp;<\/p>\n\n\n\n<p>Go to STEP-11&nbsp;<\/p>\n\n\n\n<p>[END OF IF]&nbsp;<\/p>\n\n\n\n<p>STEP-2: SET NEW_NODE = PTR&nbsp;<\/p>\n\n\n\n<p>STEP-3: SET PTR = PTR -&gt; NEXT&nbsp;<\/p>\n\n\n\n<p>STEP-4: SET NEW_NODE -&gt; DATA = VAL&nbsp;<\/p>\n\n\n\n<p>STEP-5: SET TEMP = HEAD<\/p>\n\n\n\n<p>&nbsp;STEP-6: Repeat STEP-8 while TEMP -&gt; NEXT== HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-7: SET TEMP = TEMP -&gt; NEXT&nbsp;<\/p>\n\n\n\n<p>[END OF LOOP]&nbsp;<\/p>\n\n\n\n<p>STEP-8: SET NEW_NODE -&gt; NEXT = HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-9: SET TEMP \u2192 NEXT = NEW_NODE&nbsp;<\/p>\n\n\n\n<p>STEP-10: SET HEAD = NEW_NODE&nbsp;<\/p>\n\n\n\n<p>STEP-11: EXIT<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/Y0eMMjRZYWkZcyCQ6TOM6iZuLuusBIH7bEOPIJcSGBc52x-Lwmkq-r9SW9dINU9uJ4JDyO6fFIj7b-9goUukVQyBzThTiqW8FCCvFYJVq4T2p368vrnguBfTbN982kizixVeQtw\" width=\"619\" height=\"326\"><\/h1>\n\n\n\n<p><strong>DELETION<\/strong><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"deletion-in-a-circular-singly-linked-list\"><strong>Deletion in a circular singly linked list:<\/strong><\/h1>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"to-delete-a-node-in-a-circular-singly-linked-list-we-have-to-make-a-few-pointers-for-adjustments\">To delete a node in a circular singly linked list, we have to make a few pointers for adjustments.&nbsp;<\/h5>\n\n\n\n<p><strong>Case 1: (The list is Empty)<\/strong><\/p>\n\n\n\n<p>If the condition <strong>head == NULL <\/strong>will become true, which means the list is empty, in this case, we just need to print <strong>underflow<\/strong>.<\/p>\n\n\n\n<p>if(head&nbsp; ==&nbsp; NULL)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>printf(\"nUNDERFLOW\");<\/p>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"return\">return;<\/h5>\n\n\n\n<p>}<\/p>\n\n\n\n<p><strong>Case 2: (The list contains a single node)<\/strong><\/p>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"if-the-condition-head-%e2%86%92-next-head-will-become-true-this-means-the-list-contains-a-single-node-in-this-case-we-have-to-delete-the-entire-list\">If the condition <strong>head \u2192 next == head <\/strong>will become true. This means the list contains a single node. In this case, we have to delete the entire list.&nbsp;<\/h5>\n\n\n\n<p>if(head-&gt;next&nbsp; ==&nbsp; head)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>head&nbsp; =&nbsp; NULL; free(head);<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"case-3-the-list-contains-more-than-one-node\"><strong>Case 3: (The list contains more than one node)<\/strong><\/h4>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"if-there-is-more-than-one-node-in-the-list-then-in-that-case-we-have-to-traverse-the-list-by-using-the-pointer-ptr\">If there is more than one node in the list, then, in that case, we have to traverse the list by using the pointer <strong>ptr.<\/strong><\/h5>\n\n\n\n<p>ptr&nbsp; =&nbsp; head;<\/p>\n\n\n\n<p>while(ptr&nbsp; -&gt;&nbsp; next&nbsp; !=&nbsp; head) ptr&nbsp; =&nbsp; ptr&nbsp; -&gt;&nbsp; next;<\/p>\n\n\n\n<p>End of the loop, the pointer points to the last node. As the last node of the list points to the head node. Now, the last node point to the next of the head node.&nbsp;<\/p>\n\n\n\n<p>o ptr-&gt;next = head-&gt;next;&nbsp;<\/p>\n\n\n\n<p>\u2022 Now, by using the free() method in the C language, free the head pointer.<\/p>\n\n\n\n<p>&nbsp;o free(head);<\/p>\n\n\n\n<p>o head = ptr-&gt;next;&nbsp;<\/p>\n\n\n\n<p>\u2022 By this way, the node deletion from the circular singly linked list will be successful.<\/p>\n\n\n\n<p><strong>Algorithm<\/strong><\/p>\n\n\n\n<p>&nbsp;STEP-1: IF HEAD = NULL&nbsp;<\/p>\n\n\n\n<p>Write UNDERFLOW<\/p>\n\n\n\n<p>&nbsp;Go to STEP-8<\/p>\n\n\n\n<p>&nbsp;[END OF IF]&nbsp;<\/p>\n\n\n\n<p>STEP-2: SET PTR = HEAD<\/p>\n\n\n\n<p>&nbsp;STEP-3: Repeat STEP-4 while PTR \u2192 NEXT == HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-4: SET PTR = PTR \u2192 next&nbsp;<\/p>\n\n\n\n<p>[END OF LOOP]&nbsp;<\/p>\n\n\n\n<p>STEP-5: SET PTR \u2192 NEXT&nbsp;<\/p>\n\n\n\n<p>&nbsp;HEAD \u2192 NEXT<\/p>\n\n\n\n<p>&nbsp;STEP-6: FREE HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-7: SET HEAD = PTR \u2192 NEXT&nbsp;<\/p>\n\n\n\n<p>STEP-8: EXIT<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/XtKj54IIeEAxc9TjN4fAAHJSsk5vfkQHn3KWbpvzTyKtfRfWKT8QYwdwNlo5OfpFBDRKVzBLCjXXzOfl_wu41x1wgvrZagKr3v4nHhs7g3rXt7Vk8TxiVmz687UN4RK9MqL0ZV8\" alt=\"\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"traversing-in-circular-singly-linked-list\"><strong>Traversing in Circular Singly linked list<\/strong><\/h3>\n\n\n\n<p>Traversing in a circular singly linked list can be possible by using a loop. Initialize the temporary pointer variable, which is temp, and it points to the head pointer and runs the while loop.<\/p>\n\n\n\n<p><strong>Algorithm&nbsp;<\/strong><\/p>\n\n\n\n<p>STEP-1: SET PTR = HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-2: IF PTR = NULL&nbsp;<\/p>\n\n\n\n<p>WRITE \"EMPTY LIST\"&nbsp;<\/p>\n\n\n\n<p>GOTO STEP-8&nbsp;<\/p>\n\n\n\n<p>END OF IF&nbsp;<\/p>\n\n\n\n<p>STEP-3: REPEAT STEP-4 AND 5 UNTIL PTR \u2192 NEXT != HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-4: PRINT PTR \u2192 DATA&nbsp;<\/p>\n\n\n\n<p>STEP-5: PTR = PTR \u2192 NEXT&nbsp;<\/p>\n\n\n\n<p>[END OF LOOP]&nbsp;<\/p>\n\n\n\n<p>STEP-6: PRINT PTR\u2192 DATA<\/p>\n\n\n\n<p>&nbsp;STEP-7: EXIT<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"searching-in-a-circular-singly-linked-list\"><strong>Searching in a circular singly linked list<\/strong><\/h3>\n\n\n\n<p>Searching in a circular singly linked list needs traversing. The item we want to search in the list is matched with each node data of the list once, if the match is found then the location of that item is returned otherwise -1 is returned.<\/p>\n\n\n\n<p><strong>Algorithm&nbsp;<\/strong><\/p>\n\n\n\n<p>STEP-1: SET PTR = HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-2: Set I = 0&nbsp;<\/p>\n\n\n\n<p>STEP-3: IF PTR = NULL&nbsp;<\/p>\n\n\n\n<p>WRITE \"EMPTY LIST\"&nbsp;<\/p>\n\n\n\n<p>GOTO STEP-8<\/p>\n\n\n\n<p>&nbsp;[END OF IF]&nbsp;<\/p>\n\n\n\n<p>STEP-4: IF HEAD \u2192 DATA = ITEM WRITE i+1 RETURN&nbsp;<\/p>\n\n\n\n<p>[END OF IF]&nbsp;<\/p>\n\n\n\n<p>STEP-5: REPEAT STEP-5 TO 7 UNTIL PTR-&gt;next == head&nbsp;<\/p>\n\n\n\n<p>STEP-6: if ptr \u2192 data = item write i+1 RETURN&nbsp;<\/p>\n\n\n\n<p>End of IF<\/p>\n\n\n\n<p>&nbsp;STEP-7: I = I + 1&nbsp;<\/p>\n\n\n\n<p>STEP-8: PTR = PTR \u2192 NEXT&nbsp;<\/p>\n\n\n\n<p>[END OF LOOP]&nbsp;<\/p>\n\n\n\n<p>STEP-9: EXIT<br><\/p>\n\n\n\n<p><strong>OPERATION ON CIRCULAR DOUBLY LINKED LIST<\/strong><\/p>\n\n\n\n<p><strong>INSERTION&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>Insertion in circular doubly linked list:<\/strong><\/p>\n\n\n\n<p>ptr&nbsp; =&nbsp; (struct&nbsp; node&nbsp; *)malloc(sizeof(struct&nbsp; node));<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If the condition <strong>head == NULL <\/strong>becomes true then, the node will be added as the first node in the circular doubly linked list.\n<ul class=\"wp-block-list\">\n<li>head = ptr;<\/li>\n\n\n\n<li>ptr -&gt; next = head;<\/li>\n\n\n\n<li>ptr -&gt; prev = head;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>In the second scenario, the condition <strong>head == NULL <\/strong>becomes false. Then, we have to make a few pointers for adjustments. We have to reach the last node of the list by traversing through the list.<\/li>\n\n\n\n<li>temp = head;<\/li>\n<\/ul>\n\n\n\n<p>while(temp -&gt; next != head)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>temp = temp -&gt; next;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Now at the end of the loop, the pointer temp would point to the last node of the list.&nbsp;<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>temp -&gt; next = ptr;<\/li>\n\n\n\n<li>ptr -&gt; prev = temp;<\/li>\n\n\n\n<li>head -&gt; prev = ptr;<\/li>\n\n\n\n<li>ptr -&gt; next = head;<\/li>\n\n\n\n<li>head = ptr;<\/li>\n<\/ul>\n\n\n\n<p><strong>Algorithm&nbsp;<\/strong><\/p>\n\n\n\n<p>STEP-1: IF PTR = NULL&nbsp;<\/p>\n\n\n\n<p>Write OVERFLOW&nbsp;<\/p>\n\n\n\n<p>Go to STEP-13&nbsp;<\/p>\n\n\n\n<p>[END OF IF]&nbsp;<\/p>\n\n\n\n<p>STEP-2: SET NEW_NODE = PTR&nbsp;<\/p>\n\n\n\n<p>STEP-3: SET PTR = PTR -&gt; NEXT&nbsp;<\/p>\n\n\n\n<p>STEP-4: SET NEW_NODE -&gt; DATA = VAL&nbsp;<\/p>\n\n\n\n<p>STEP-5: SET TEMP = HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-6: Repeat STEP-7 while TEMP -&gt; NEXT == HEAD<\/p>\n\n\n\n<p>&nbsp;STEP-7: SET TEMP = TEMP -&gt; NEXT&nbsp;<\/p>\n\n\n\n<p>[END OF LOOP]&nbsp;<\/p>\n\n\n\n<p>STEP-8: SET TEMP -&gt; NEXT = NEW_NODE&nbsp;<\/p>\n\n\n\n<p>STEP-9: SET NEW_NODE -&gt; PREV = TEMP&nbsp;<\/p>\n\n\n\n<p>STEP-10 : SET NEW_NODE -&gt; NEXT = HEAD&nbsp;<\/p>\n\n\n\n<p>STEP-11: SET HEAD -&gt; PREV = NEW_NODE<\/p>\n\n\n\n<p>&nbsp;STEP-12: SET HEAD = NEW_NODE&nbsp;<\/p>\n\n\n\n<p>STEP-13: EXIT<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/s1hXknTa63ZvAHp6Ujyha61dy-AQ-UIri1VwODtlxoVvdG1Zrl1IM_GTHHrpmAUy-ZX8HlGPkhQpPqCqZtDKpnsSg3ndj6YDWprqI4Ibn2ayu_gWPv8Gx0H1RTZ-QFxwLbmmSTA\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>DELETION<\/strong><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"deletion-in-a-circular-doubly-linked-list\"><strong>Deletion in a Circular doubly linked list:<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The conditioning head \u2192 next == head will become true, then the list needs to be completely deleted.<\/li>\n\n\n\n<li>Assign head pointer of the list to null(head==NULL).\n<ul class=\"wp-block-list\">\n<li>head = NULL;<\/li>\n\n\n\n<li>free(head);<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>The list contains more than one element in the list, then the condition <strong>head \u2192 next == head <\/strong>will become false\n<ul class=\"wp-block-list\">\n<li>temp = head;<\/li>\n\n\n\n<li>while(temp -&gt; next != head)<\/li>\n\n\n\n<li>{<\/li>\n\n\n\n<li>temp = temp -&gt; next;<\/li>\n\n\n\n<li>}<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>temp will point to the last node.\n<ul class=\"wp-block-list\">\n<li>temp -&gt; next = head -&gt; next;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>The new head node\n<ul class=\"wp-block-list\">\n<li>head -&gt; next -&gt; prev = temp;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Now, free the head pointer and make its next pointer.\n<ul class=\"wp-block-list\">\n<li>free(head);<\/li>\n\n\n\n<li>head = temp -&gt; next;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>Algorithm&nbsp;<\/strong><\/p>\n\n\n\n<p>Step-1: IF HEAD = NULL&nbsp;<\/p>\n\n\n\n<p>Write UNDERFLOW&nbsp;<\/p>\n\n\n\n<p>Go to STEP-8&nbsp;<\/p>\n\n\n\n<p>[END OF IF]&nbsp;<\/p>\n\n\n\n<p>Step-2: SET TEMP = HEAD&nbsp;<\/p>\n\n\n\n<p>Step-3: Repeat STEP-4 while TEMP --&gt; NEXT == HEAD&nbsp;<\/p>\n\n\n\n<p>Step-4: SET TEMP = TEMP -&gt; NEXT&nbsp;<\/p>\n\n\n\n<p>[END OF LOOP]&nbsp;<\/p>\n\n\n\n<p>Step-5: SET TEMP -&gt; NEXT&nbsp;<\/p>\n\n\n\n<p>&nbsp;HEAD -&gt; NEXT&nbsp;<\/p>\n\n\n\n<p>Step-6: SET HEAD -&gt; NEXT --&gt; PREV = TEMP&nbsp;<\/p>\n\n\n\n<p>Step-7: FREE HEAD&nbsp;<\/p>\n\n\n\n<p>Step-8: SET HEAD = TEMP -&gt; NEXT<\/p>\n\n\n\n<p>Step-9: EXIT<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/ymsb94Uy6q4uw0gD1UXO-JO45cDorHFu0eLVdk0UZPCENrWFrWN1JsCsVmS2QnEIZPhq-U_NdJOkrweHhu2GmM3mITiQStu0a6Znu0pviq0jwvVcNjb7cN4of-w-54RanBpPR68\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>ADVANTAGES AND DISADVANTAGES<\/strong><\/p>\n\n\n\n<p><strong>ADVANTAGES<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Linked Lists are dynamic data structure.&nbsp;<\/li>\n\n\n\n<li>Efficient memory utilization. Memory is allocated whenever it is required.&nbsp;<\/li>\n\n\n\n<li>Insertion and deletion are easier and efficient as compilers to others.<\/li>\n<\/ul>\n\n\n\n<p><strong>DISADVANTAGES<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Memory is required to store an integer number is more.&nbsp;<\/li>\n\n\n\n<li>It is time-consuming.<\/li>\n<\/ul>\n\n\n\n<p><strong>REAL\/ PRACTICAL APPLICATIONS OF LINKED LIST:-<\/strong><\/p>\n\n\n\n<p>There is much real-life example of linked lists like- Train cars\/coach, traffic light, chains etc. If we decide it category wise then-<br><strong>1) For a Singly linked list<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Child brain (eg. In case a child recited a poem, if you ask him the last line then, he will have to read from the first line of the poem again as he cannot remember the last line directly).<br><\/li>\n\n\n\n<li>Traffic light (there are three signals \u2013 red, yellow and green). If we are at a stop position in the traffic light, we will first see the red and the green signal. After green, we see the yellow signal for a few seconds, and we cannot go directly to the red signal.<\/li>\n<\/ul>\n\n\n\n<p><strong>2) Doubly linked list<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>DNA double-helix structure&nbsp;<\/li>\n\n\n\n<li>Train coaches&nbsp;<\/li>\n\n\n\n<li>Roller chain of bicycle\/bike<\/li>\n\n\n\n<li>Undo functionality in photoshop or word<\/li>\n<\/ul>\n\n\n\n<p><strong>3) Circular linked list<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The time-sharing problem used in the operating system.<\/li>\n\n\n\n<li>&nbsp;Boardgame (Multiple players)<\/li>\n\n\n\n<li>&nbsp;Used to repeat the songs in a playlist<\/li>\n\n\n\n<li>Audio-video streaming<\/li>\n<\/ul>\n\n\n\n<p><strong>Conclusion- <\/strong>These operations are functional in many real\/ practical applications. We learned how to traverse, append, insert and delete nodes from the linked list. Suppose we take the example of a PowerPoint presentation, where nodes are slides that are serially linked with one another. Many other applications may require thinking of the function of the list, where the list can easily be maintained.<\/p>\n\n\n\n<p>Learn C++ from basics to advanced concepts like OOP and memory management. With Our PRO C++ Programming for Beginners to Advanced course and it will help you build real-world skills for high-demand roles in software development, game programming, and more. Mastering C++ will give your career a boost with opportunities in industries like tech and finance.<\/p>\n\n\n\n    <div class=\"courses-cta-container\">\n        <div class=\"courses-cta-card\">\n            <div class=\"courses-cta-header\">\n                <div class=\"courses-learn-icon\"><\/div>\n                <span class=\"courses-learn-text\">Academy Pro<\/span>\n            <\/div>\n            <p class=\"courses-cta-title\">\n                <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/learn-c-programming-for-beginners-to-advanced\" class=\"courses-cta-title-link\">C++ Programming Course<\/a>\n            <\/p>\n            <p class=\"courses-cta-description\">Master key C++ programming concepts like variables, functions, OOP, and control structures. Build real-world projects such as a banking system and grade management tool.<\/p>\n            <div class=\"courses-cta-stats\">\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-user-icon\"><\/div>\n                    <span>Beginner to Advanced Level<\/span>\n                <\/div>\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-star-icon\"><\/div>\n                    <span>8.1 hrs<\/span>\n                <\/div>\n            <\/div>\n            <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/learn-c-programming-for-beginners-to-advanced\" class=\"courses-cta-button\">\n                Start Free Trial\n                <div class=\"courses-arrow-icon\"><\/div>\n            <\/a>\n        <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>INTRODUCTION -It is a sequence of items (objects) where every item is linked to the next. They are linked to one another through pointers. There are two parts in each node: the first part contains the data, and the second part contains the address of the next node in the linked list. Address part of [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":31057,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[36801],"content_type":[],"class_list":["post-31899","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-c-programming"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>LINKED LIST IN C++<\/title>\n<meta name=\"description\" content=\"A linked list in C++ is defined as the address part of the node which is connected to the next link. A linked list in C++ is a form of data structure.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"LINKED LIST IN C++\" \/>\n<meta property=\"og:description\" content=\"A linked list in C++ is defined as the address part of the node which is connected to the next link. A linked list in C++ is a form of data structure.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-04-20T16:16:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-13T10:51:54+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1251\" \/>\n\t<meta property=\"og:image:height\" content=\"838\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"19 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/link-in-c\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/link-in-c\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"LINKED LIST IN C++\",\"datePublished\":\"2021-04-20T16:16:32+00:00\",\"dateModified\":\"2024-11-13T10:51:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/link-in-c\\\/\"},\"wordCount\":3398,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/link-in-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/iStock-488651322-1.jpg\",\"keywords\":[\"C++ Programming\"],\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/link-in-c\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/link-in-c\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/link-in-c\\\/\",\"name\":\"LINKED LIST IN C++\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/link-in-c\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/link-in-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/iStock-488651322-1.jpg\",\"datePublished\":\"2021-04-20T16:16:32+00:00\",\"dateModified\":\"2024-11-13T10:51:54+00:00\",\"description\":\"A linked list in C++ is defined as the address part of the node which is connected to the next link. A linked list in C++ is a form of data structure.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/link-in-c\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/link-in-c\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/link-in-c\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/iStock-488651322-1.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/iStock-488651322-1.jpg\",\"width\":1251,\"height\":838,\"caption\":\"Software developer programming code on computer. Abstract computer script source code.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/link-in-c\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IT\\\/Software Development\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/software\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"LINKED LIST IN C++\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"LINKED LIST IN C++","description":"A linked list in C++ is defined as the address part of the node which is connected to the next link. A linked list in C++ is a form of data structure.","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:\/\/www.mygreatlearning.com\/blog\/link-in-c\/","og_locale":"en_US","og_type":"article","og_title":"LINKED LIST IN C++","og_description":"A linked list in C++ is defined as the address part of the node which is connected to the next link. A linked list in C++ is a form of data structure.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2021-04-20T16:16:32+00:00","article_modified_time":"2024-11-13T10:51:54+00:00","og_image":[{"width":1251,"height":838,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1.jpg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"19 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"LINKED LIST IN C++","datePublished":"2021-04-20T16:16:32+00:00","dateModified":"2024-11-13T10:51:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/"},"wordCount":3398,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1.jpg","keywords":["C++ Programming"],"articleSection":["IT\/Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/","url":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/","name":"LINKED LIST IN C++","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1.jpg","datePublished":"2021-04-20T16:16:32+00:00","dateModified":"2024-11-13T10:51:54+00:00","description":"A linked list in C++ is defined as the address part of the node which is connected to the next link. A linked list in C++ is a form of data structure.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1.jpg","width":1251,"height":838,"caption":"Software developer programming code on computer. Abstract computer script source code."},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/link-in-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"IT\/Software Development","item":"https:\/\/www.mygreatlearning.com\/blog\/software\/"},{"@type":"ListItem","position":3,"name":"LINKED LIST IN C++"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1.jpg",1251,838,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1-150x150.jpg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1-300x201.jpg",300,201,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1-768x514.jpg",768,514,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1-1024x686.jpg",1024,686,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1.jpg",1251,838,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1.jpg",1251,838,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1-640x838.jpg",640,838,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1-96x96.jpg",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-488651322-1-150x100.jpg",150,100,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"INTRODUCTION -It is a sequence of items (objects) where every item is linked to the next. They are linked to one another through pointers. There are two parts in each node: the first part contains the data, and the second part contains the address of the next node in the linked list. Address part of&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/31899","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=31899"}],"version-history":[{"count":9,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/31899\/revisions"}],"predecessor-version":[{"id":111533,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/31899\/revisions\/111533"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/31057"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=31899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=31899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=31899"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=31899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}