Singly Linked List (SLL) Merging operation, Merge function/algorithm

Merging:- Merging is a process of combining the nodes of two or more Singly Linked List into a new Singly Linked List of same type. The number of nodes of resultant Singly Linked List is the sum of nodes of all combined Linked List.
मर्जिंग:- मर्जिंग वह प्रक्रिया है जिसमे एक ही प्रकार के दो या दो से अधिक सिंगली लिंक्ड लिस्ट को आपस में जोड़कर एक परिणामी सिंगली लिंक्ड लिस्ट तैयार किया जता है। परिणामी सिंगली लिंक्ड लिस्ट में नोड्स की संख्या, जोड़े गए सभी लिंक्ड लिस्ट के नोड्स की संख्या के योग के बराबर होती है। 
In following function/algorithm we combine two SLL-
निम्न फंक्शन या अल्गोरिथम में दो SLL को आपस में जोड़ा गया है- 

//Merging of two SLL
void mergesll (NODE *start1,NODE *start2){
NODE *temp=start1;
clrscr();
if(start1==NULL||start2==NULL){
printf("either one or both SLL are not Exist!!\nMerging Operation Failed\n");
getch();
return;
}
while(temp->link!=NULL){
temp=temp->link;
}
temp->link=start2;
start2=NULL;
printf("Merging operation performed Successfully in SLL\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...