Let k=no. of rows

If k=odd
mirror the matrix about the ((k/2)+1) th row..

else start from k/2 and (k/2 +1 )th row, swap the two rows.. then
k/2-1 and k/2 +2 and swap and soon...

OR

maintain array as a pointer table.. keep on changing the base address
to which a[i points to..

Let *a[]={{1,1,0},{2,3,4},{4,57,8},{1,2,5}};

Take pointer a[0] and swap it with the a[3] address.. lly for a[2]and a[1]...
This should run in O(n) time ,n=no of rows of matrix
I think i made it clear...

This might not be the best solution... i wud love to see better
solutions from anyone..!

Thanks..

On 7/27/11, Deoki Nandan <deok...@gmail.com> wrote:
> rotate a 2D matrix by angle 180
>
>
> --
> **With Regards
> Deoki Nandan Vishwakarma
>
> *
> *
>
> --
> 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