int merge(int arr[],int n)
{
int l=0;
int j=(n/3);
int k=2*(n/3);
int *a=(int*)malloc(sizeof(int)*n);
for(int i=0;i<n/3;i++)
{
a[l++]=arr[i];
a[l++]=arr[j++];
a[l++]=arr[k++];
}
for(int i=0;i<n;i++)
arr[i]=a[i];
free(a);
}
cud be dun be dun recursively also to minimize d space complexity...





On Sat, Aug 4, 2012 at 8:20 AM, Navin Kumar <[email protected]>wrote:

> In given array of elements like [a1,a2,a3,..an,b1,b2,b3,..bn,c**1,c2,c3,...cn]
> .Write an efficient program to merge them like
> [a1,b1,c1,a2,b2,c2,...an,bn,cn**].
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/gVCyxQV1IhAJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to