[algogeeks] Re: shortest swapping rows

2011-08-26 Thread Algo'nAlgo
Its O(n*n) algo.. so you have to just iterate n times.. please take an exampla and solve it.. u'll get to know urself :) On Aug 19, 3:14 am, Prakash D cegprak...@gmail.com wrote: hey, thanks.. but if it needs many iteration, then we've to check each time whether the array is sorted.. is there

Re: [algogeeks] Re: shortest swapping rows

2011-08-18 Thread Prakash D
hey, thanks.. but if it needs many iteration, then we've to check each time whether the array is sorted.. is there any better way for swapping On Thu, Aug 18, 2011 at 5:02 AM, Brijesh Upadhyay brijeshupadhyay...@gmail.com wrote: IT is the question.. You are given an N x N matrix with 0 and 1

[algogeeks] Re: shortest swapping rows

2011-08-17 Thread Brijesh Upadhyay
Make an array of size n, and fill it with index of last 1 of corresponding row in the matrix.. as if row 0 has 1101100 , than arr[0]=4 . so we end up with an array containing last position of 1 in the respective row.. lets arr[4] is like 3,2,2,1... we have to make it 1,2,2,3.. so now apply

[algogeeks] Re: shortest swapping rows

2011-08-17 Thread Brijesh Upadhyay
IT is the question.. You are given an N x N matrix with 0 and 1 values. You can swap any two adjacent rows of the matrix. Your goal is to have all the 1 values in the matrix below or on the main diagonal. That is, for each X where 1 ≤ X ≤ N, there must be no 1 values in row X that are to