On Sun, Jun 27, 2010 at 1:57 AM, jalaj jaiswal <[email protected]>wrote:
>
> Given an array of integers, {1,0,2,0,3,0,0,4,5,6,7,0,0,0}, you have to
> create a new array which will be like (1,2,3,4,5,6,7,0,0,0,0,0,0,0}, without
> using any other temporary array.
>
>
>
>
//******************************************************************************
Algorithm:-
int i,k;
i=k=0;
int ar[]={ 1,0,2,0,3,0,0,4,5,6,7,0,0,0};
for <- i to sizeofArray-1
{
if(ar[i] !=0)
i++
else
{
k=i+1
while(ar[k] ==0)
k++
swap ar[i] <---->ar[k]
i++
}
}
UMESH KUMAR
PERSUING MCA FROM
UNIVERSITY OF DELHI
+919958120503
--
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.