Singly Linked List (SLL) traversing/visiting operation, traverse function/algorithm

Traversing or Visiting:- Accessing or visiting of each node present in Singly Linked List is known as Traversing.
ट्रेवर्सिंग या विसिटिंग:- सिंगली लिंक्ड लिस्ट के सभी नोड्स को एक्सेस या विजिट करना, ट्रेवर्सिंग कहलाता है।    
Let Assume that SLL was previously created by createsll() and start pointing to the fisrt node of SLL.
माना कि createsll() द्वारा SLL तैयार की गयी है, जिसके प्रथम नोड का एड्रेस स्टार्ट नामक पॉइंटर वेरिएबल में रखा गया है  

//traverse SLL
void traversesll(){
NODE *temp=start;
int i=0;
clrscr();
if(temp==NULL){
printf("Linked list is Empty\n");
getch();
return;
}
printf("Linked list is:-\n");
while(temp!=NULL){i++;
printf("Node No:-%d\n info part= %d\nLink Part=%u\n",i,temp->info,temp->link);
temp=temp->link;
}
printf("Linked List Traversed \n %d Node's are Visited.\nstart=%u",i,start);
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...