Q. Write down an algorithm to merge the two sorted arrays into the third array. Do not perform the sort function in the third array.
Ans:
void merge(int *a,int *b,int n,int m)
{
int i=0,c[20],j=0,k=0,count=0;
while(i<=n&&j<=m)
{
if(a[i]
{
c[k]=a[i];
i++;
k++;
}
if(a[i]>b[j])
{
c[k]=b[j];
j++;
k++;
}
if(a[i]==b[j])
{
c[k]=a[i];
k++; i++; j++;
count++;
}
}
if(i<=n&&j==m)
{
while(i<=n)
{
c[k]=a[i];
i++;
k++;
}
}
if(i==n&&j<=m)
{
while(j<=m)
{
c[k]=b[j];
i++;
j++;
}
}
for(i=0;i
printf("%d\t",c[i]);
}