A Doubly Linked List Data Structure will have nodes that have:
- Data
- Address which points to the next node
- Address which points to the previous node
So navigation is possible both ways (forwards and backwards).
Operations
Operation Name | Operations |
---|---|
Insertion | Insertion at the start,end and after a particular node |
Deletion | Deletion at the start,end and of a particular node |
Traversing | Going through each node and performing some action |
Searching | Comparing each data node with some item being searched for |
Reverse | Reverse the entire list |
Update | Modify a data node with a given value |
Implementation in C++
We know that each node in a doubly linked list (DLL) has 3 parts:
- Data
- previous pointer
- next pointer
So let's code the basic structure/blueprint of a DLL
#include <iostream>
using namespace std;
//declare a structure data called Node
struct Node {
//declare integer data type called data
int data;
//declare the previous & next pointer of the *Node* structure data type
struct Node *prev;
struct Node *next;
};
Top comments (0)