u have mentioned clockwise, but o/p u r giving is anti-clock wise.

solution for clockwise :

See Reverse last k and first n-k numbers e.g.
5 4 3 2 1 8 7 6

now reverse whole array.
6 7 8 1 2 3 4 5.

solution for anti-clockwise :
 See Reverse first k and last n-k numbers e.g.
3 2 1 8 7 6 5 4

now reverse whole array.

4 5 6 7 8 1 2 3

Hope u got it.

Sanju
:)



On Fri, Aug 26, 2011 at 10:49 PM, Dheeraj Sharma <
dheerajsharma1...@gmail.com> wrote:

> How to rotate 1d array of length clockwise 'k' times??
> (1,2,3,4,5,6,7,8)->(4,5,6,7,8,1,2,3) for k=3 n= 8
>
> Give solutions which do not swap the array k times!! i.e less than O(nk)
>
> --
> *Dheeraj Sharma*
> Comp Engg.
> NIT Kurukshetra
> +91 8950264227
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> 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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to