Doubly Linked List (DLL) Introduction and creation operation, create function/algorithm

Doubly Linked List ( डबली लिंक्ड लिस्ट) :-
Doubly Linked List is a linear data structure. It is a collection of nodes in linear order which is divided in three parts back part, info part and next part. The back part points to the previous node, the info part stores information and the next part points to the next node of Doubly Linked List. 
Doubly Linked List is also called dynamic data structure because we can create and modify number of nodes in Linked List at run time. 
we can perform both forward and backward traversing operation in DLL, so it is called two way linked list.
we store null value at next part of last node and back part of first node of DLL. 
Address of first and last node of DLL are stored in first and last external pointer variable.

डबली लिंक्ड लिस्ट एक लीनियर डाटा स्ट्रक्चर है इसे श्रेणी क्रम में व्यवस्थित नोड्स का संग्रह माना जाता है। यह नोड तीन भागो में विभाजित होता है बेक पार्ट, इन्फो पार्ट एवं नेक्स्ट पार्ट। यहाँ बेक पार्ट द्वारा DLL के पिछले नोड को पॉइंट किया जाता है , इन्फो पार्ट द्वारा नोड से सम्बंधित जानकारी राखी जाती है एवं नेक्स्ट पार्ट द्वारा DLL के अगले नोड को पॉइंट किया जाता है।
डबली लिंक्ड लिस्ट को डायनामिक डाटा स्ट्रक्चर भी कहा जाता है क्यूंकि डबली लिंक्ड लिस्ट में हम नोड का निर्माण एवं नोड की संख्या में परिवर्तन रन टाइम पर कर सकते है।
डबली लिंक्ड लिस्ट में फॉरवर्ड एवं बैकवर्ड दोनों ट्रेवरसींग की जा सकती है इसीलिए इसे टू वे लिंक्ड लिस्ट भी कहा जाता है।
हम DLL के अंतिम नोड के नेक्स्ट पार्ट पर एवं प्रथम नोड के बैक पार्ट पर नल वैल्यू स्टोर करते है। 
DLL के प्रथम नोड का एड्रेस फर्स्ट एवं अंतिम नोड का एड्रेस लास्ट नामक एक्सटर्नल पॉइंटर वेरिएबल में रखते है।   


Creation:- Creating a Doubly Linked List according to the requirement.
क्रिएशन:- अपनी आवश्यकतानुसार डबली लिंक्ड लिस्ट को तैयार करना।  

DLL create Function/Algorithm:-

//structure of Node.
struct node{
struct node *back;
int info;
struct node *next;
};
typedef struct node NODE;
NODE *first=NULL,*last=NULL,*n=NULL;

//creation of DLL.
void createdll(){
int ch=1,item;
while(ch==1){
clrscr();
n= malloc(sizeof(NODE));
if(n==NULL){
printf("Overflow Condition\n");
getch();
return;
}
printf("Enter item to insert\n");
scanf("%d",&item);
n->info=item;
n->back=NULL;
if(first==NULL){
n->next=NULL;
first=last=n;
}
else{
n->next=first;
first->back=n;
first=n;
}
printf("Do you want to add another node\n if yes press 1 \n if no press 0\n");
scanf("%d",&ch);
}
printf("Doubly Linked List Created\n");
getch();
return;
}

No comments:

Post a Comment

Stack Data Structure, Push, Pop and Peek Operations , Applications of Stack

Stack is a linear data structure. It is collection of ordered data elements. It is also known as LIFO system (last in first out). It means i...