Singly Linked List (SLL) Introduction and Creation Create function/algorithm

Singly/ Linear/ Simple Linked List ( सिंगली/ लीनियर / सिंपल लिंक्ड लिस्ट) :-

Singly Linked List is a linear data structure. It is a collection of nodes in linear order which is divided in two parts info part and link part. Here link is a self referential pointer variable which is used to form a chain by pointing next node of Linked List. 
Singly Linked List is also called dynamic data structure because we can create and modify number of nodes in Linked List at run time. 
It is also called One Way Linked List because we can perform forward traversing in SLL only.
we store null value at link part of last node of SLL and first node of SLL is pointed by start external pointer variable. 

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



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

Singly Linked List (SLL)  Create Function/Algorithm 

//Node Definition
struct node{
int info;
struct node *link;
};
typedef struct node NODE;
NODE *start=NULL ,*n=NULL;

//create SLL function
void createsll(){
int item,ch=1;
while(ch==1){
clrscr();
n= malloc(sizeof(NODE));
if(n==NULL){
printf("Overflow Condition\n");
getch();
return;
}
printf("Enter item \n");
scanf("%d",&item);
n->info=item;
if(start==NULL){
n->link=NULL;}
else{
n->link=start;}
start=n;
printf("Do You want to add another node \npress 1 if YES \npress 0 if NO\n");
scanf("%d",&ch);
}
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...