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 3 4 8 9 1 2 4 8 9 1 2 3 4 9 1 2 3 4 9 1 2 3 4 5 1 2 3 4 5 2 5 18 25 50 3 5 18 25 50 8 5 18 25 50 sorting 5 8 18 25 50 9 8 18 25 50 8 9 18 25 50 6 7 22 45 55 --->.............--->...........------------>.........---->...........--->6 7 22 45 55----> 1 2 3 4 5 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, Lucifer <sourabhd2...@gmail.com> wrote: > @atul.. > > Complexity of heapifying(basically re-stabalizing the heap) is (m - i > + j) when an element A[i][j] is swapped with A[i+1][0] as an impact of > A[i][j] > A[i+1][0].. > > On Jan 11, 4:44 pm, Dipit Grover <dipitgro...@gmail.com> wrote: >> @Shady : you would definitely need two index variables for each array I >> feel. > > -- > 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. > > -- 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.