Page 85 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 85
Fundamentals of Data Structures
Notes printf(“The elements of merged list is \n”);
display(c,10);
getch();
}
void read(int c[],int i)
{
int j;
for(j=0;j<i;j++)
scanf(“%d”,&c[j]);
}
void display(int d[],int i)
{
int j;
for(j=0;j<i;j++)
printf(“%d “,d[j]);
printf(“\n”);
}
void sort(int arr[], int k)
{
int temp;
int i,j;
for(i=0;i<k;i++)
{
for(j=0;j<k-i-1;j++)
{
if(arr[j]<arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
}
void mergelist(int a[],int b[],int c[],int k)
{
int ptra=0,ptrb=0,ptrc=0;
while(ptra<k && ptrb<k)
{
if(a[ptra] < b[ptrb])
{
c[ptrc]=b[ptrb];
78 LOVELY PROFESSIONAL UNIVERSITY