Doubly Linked List(DLL) searching operation, search function/algorithm

Searching:- To find a given item into Doubly Linked List is known as Searching. when searching is successful then it will provide location or position of the node Otherwise, it will return null value.
सर्चिंग:- डबली लिंक्ड लिस्ट में किसी दिए गए आइटम (मान) को खोजना, सर्चिंग कहलाता है। जब सर्चिंग संक्रिया सफल होती है, तब उस नोड की लोकेशन या पोजीशन प्रदान की जाती है अन्यथा नल वैल्यू रिटर्न की जाती है।

Let Assume that DLL was previously created by createdll() and first pointing to the first node of DLL and item is given in input by user.
माना कि createdll() द्वारा  DLL तैयार की गयी है, जिसके प्रथम नोड का एड्रेस फर्स्ट नामक पॉइंटर वेरिएबल में रखा गया है एवं आइटम यूजर द्वारा इनपुट के रूप में दिया गया है  

//search an item in DLL
void searchdll(int item){
NODE *temp=first;
int i=0;
clrscr();
if(temp==NULL){
printf("Doubly Linked List is Not Exist\n");
getch();
return;
}
while(temp!=NULL){
i++;
if(item==temp->info){
printf("Searching is Successful\n%d is found at location=%u\n Node no= %d\n back part=%u \n info part= %d \n next part= %u\n",item,temp,i,temp->back,temp->info,temp->next);
getch();
return;
}
temp=temp->next;
}
printf("%d is not found in DLL\nSearching is Unsuccessful!!\n",item);
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...