i think this should work.

for(i=1;i<=k;i++)
{
var=a[n-1]
for(j=n-1;j>=1;j--)
a[i]=a[i-1]
a[0]=var
}

On Fri, Jul 2, 2010 at 5:36 PM, Saurabh Ahuja <[email protected]>wrote:

> a[0] = a[2]
> a[1] = a[3]
> a[2] = a[4]
>
> a[0] and a[1] has been changed
> a[3] = a[0]
> a[4] = a[1]
>
> so this solution would not work.
>
>
> On Fri, Jul 2, 2010 at 5:14 PM, Akash Gangil <[email protected]> wrote:
>
>> wouldn't this work:
>>
>>
>>
>> for i in range(0,len)
>>     a[i] = a[(i+2)%5];
>>
>> where len is the length of array
>>
>>
>> On Sat, Jun 26, 2010 at 3:37 PM, sharad kumar 
>> <[email protected]>wrote:
>>
>>> i have to right rotate an array by k positions
>>> 1 2 3 4 5 for k=2 o/p shud be
>>> 3 4 5 1 2
>>>
>>>
>>> P.S---do not give block reversal method for array rotation and soln must
>>> be inplace.....plzz write ur logic also along with d code
>>>
>>> --
>>> 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]<algogeeks%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Best Regards
>> Akash Gangil
>>
>>  --
>> 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]<algogeeks%[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]<algogeeks%[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