IMPLEMENTATION OF MERGE SORT
PROGRAM:
#include
#include
#include
int n;
void main()
{
int i,low,high;
int a[20];
void mergesort(int a[10],int low,int high);
void display(int a[10]);
clrscr();
printf("\n\tMerge Sort");
printf("\n Enter the size of elements");
scanf("%d",&n);
printf("\n Enter the list element");
for(i=0;i
low=0;
high=n-1;
mergesort(a,low,high);
display(a);
getch();
}
void mergesort(int a[10],int low,int high)
{
int mid;
void combine(int a[10],int low,int mid,int high);
if(low
mid=(low+high)/2;
mergesort(a,low,mid);
mergesort(a,mid+1,high);
combine(a,low,mid,high);
}
}
void combine(int a[10],int low,int mid,int high)
{
int i,j,k;
int temp[10];
k=low;
i=low;
j=mid+1;
while(i<=mid&&j<=high)
{
if(a[i]<=a[j])
{
temp[k]=a[i];
i++;
k++;
}
else
{
temp[k]=a[j];
j++;
k++;
}
}
while(i<=mid)
{
temp[k]=a[i];
i++;
k++;
}
while(j<=high)
{
temp[k]=a[j];
j++;
k++;
}
for(k=low;k<=high;k++)
a[k]=temp[k];
}
void display(int a[10])
{
int i;
printf("\n\n The Sorted Array is.......");
for(i=0;i
}
OUTPUT:
Merge Sort
Enter the size of elements 5
Enter the list element
9
8
7
6
5
The Sorted Array is.......5 6 7 8 9
CIET college Programs,LAB Programs for Engineering Students,DAA LAB Programs,DSA LAB Programs,Remoboys,karthik,Remokn,Student3k,programs source code,Design Analysis And Algorithms LAB Programs,Data Structures and Algorithms LAB Programs,LAB Codings,Coimbatore Institute of Engineering and Technology ( CIET )
Wednesday, September 22, 2010
IMPLEMENTATION OF MERGE SORT
9:24 AM
Karthikh Venkat
Popular Posts( Last 7 Days )
-
South Indian Hot Sexy Actress Kalpana Chowdary Too Sizzling Glamour Photos Kalpana Chowdary, Kalpana Chowdary Hot Sexy nude mms, Kalpana Cho...
-
account from a guest account by which you can reset the administrator Ever wanted to hack your college pc with guest account/student account...
-
Learning how to prevent skin cancer requires focusing your efforts each and every day on protecting your skin. If you can keep your skin ...
-
Ravi Teja's Veera Movie Stills stars : Ravi Teja, Kajal, Taapsee, Kick Shaam, Sridevi, Prakash Raj, Brahmanandam directed by Ramesh Varm...
-
tamil actress seetha latest photos, actress seetha hot images, actress seetha parthiban hot pics, tamil actress seetha prostitution, act...