@pankajsingh, did u observe the array in the 4th step?
I think it will be like this

1 2 3 4 9
5 8 18 25 50
6 7 22 45 55

The second column is not sorted. You need to sort not only the rows, but
also the columns accordingly. I think it will become more complex.


On Wed, Jan 11, 2012 at 5:51 PM, pankajsingh <psingh...@gmail.com> wrote:

> I thought of a simpler algo, i m using the property of this matrix
> That is. a[i][0] is smallest of a[i][] and a[i+1][]....so on,so to
> decide next smallest element i will only consider
> a[i][0]...
>
> i will swap element if required and sort the row(too by swapping) if
> element are changed.
>
> on the above example
>
> 1)1 3 4 8 9
> 2 5 18 25 50
> 6 7 22 45 55
>
> 2)
> 1 2 4 8 9
>
> 3 5 18 25 50
> ............
>
>
> 3)
> 1 2 3 4 9
> 8 5 18 25 50
>
> ...........
> sorting
> 4)
> 1 2 3 4 9
>
> 5 8 18 25 50
> .........-
>
> 5)
> 1 2 3 4 5
> 9 8 18 25 50
> ..........
> 6)
> 1 2 3 4 5
> 8 9 18 25 50
> 6 7 22 45 55
>
> 7)
>
> 1 2 3 4 5         8) 1 2 3 4 5
> 6 9 18 25 50       6 9---
> 8 7 22 45 55--->   7 8 22.....and so on...
>
> for swapping without space use
> a=a+b;
> b=a-b;
> a=a-b;
> it worked for examples i had taken....pls notice me if any flaw with this..
>
> On 1/11/12, pankajsingh <psingh...@gmail.com> wrote:
> > srry some formatting problem...i will repost later.......
> >
>
>
> --
> Pankaj Singh
> B.Tech in Computer Science and Engineering - lllrd year
> IIT Roorkee, India
>
> --
> 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