menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Data struc...
source image

Prodevelopertutorial

3w

read

192

img
dot

Image Credit: Prodevelopertutorial

Data structure tutorial 4: Doubly Linked List [DLL]

  • Doubly Linked List is a special data structure, which is a collection of zero or more nodes.
  • Each node is made up of 3 parts, prev_link + data + next_link.
  • In a Doubly Linked List, we need to store the address information for the previous node and the next node.
  • The DLL operations include inserting an element at the rear, deleting an element with a given key value, searching for an element and displaying all the data.
  • The implementation of DLL includes defining structures for nodes, head pointer, and the 4 defined operations.
  • The C++ code presented inserts, deletes, searches and displays elements in a DLL.
  • When inserting elements at the rear, we check if head node is NULL.
  • If the head element is not NULL, we use the next pointer to move to the end of the list to add the element.
  • To delete an element we move the pointer temp to the element with that key, then update pointers for adjacent nodes before deleting the temp node.
  • To search an element we move the temp pointer to the head and check if the data is the same as key.

Read Full Article

like

11 Likes

For uninterrupted reading, download the app