Here it is: http://arxiv.org/PS_cache/arxiv/pdf/0805/0805.1598v1.pdf

On Jun 27, 5:02 am, Ankit Sablok <[email protected]>
wrote:
> Need a Better Algorithm
>
> here is a trivial question we are given an array of 2n elements in the
> form
> {a1,a2,a3,......,an,b1,b2,b3b.......bn}
>
> we need to output a resultiing array in the form
> {a1,b1,a2,b2........,an,bn}
> but without using another array here is my algorithm which uses nested
> loops can anyone provide a better solution which doesnt involve
> shifting.
>
> int i,j,k,temp;
> j=num;
>
> int Interleave(int *arr)
> {
>
>     for(i=1;i<2*num - 1;i+=2)
>     {
>       temp = arr[j];
>
>       for(k=j;k>=i+1;--k)
>       arr[k]=arr[k-1];
>
>       arr[i] = temp;
>       ++j;
>     }
>
>
>
>
>
>
>
> }

-- 
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