yah this is a good approach...but one thing in worst case it would be m^2 instead of n^2
On Sat, Aug 20, 2011 at 3:22 PM, Sanjay Rajpal <srn...@gmail.com> wrote: > Yes, thats right. > I think we can do the following also : > > Lets us assume rows are sorted in increasing order. > > start from first row say i. Traverse the array from the end of the row > towards the beginning till 0 occurs say at position j. > now proceed to the next row i+1, check the value at i+1,j if it is 0, go > to next row i+2,j > else if its 1, then go to left till 0 occurs and store that index of 0 and > follow to the next row. > > In the worst case, it will be O(n^2), but in general its a good approach i > guess. what do u say guys ? > > Average Case O(m+n) ? > > > Sanju > :) > > > > On Sat, Aug 20, 2011 at 2:47 AM, shady <sinv...@gmail.com> wrote: > >> binary search on every row which will give solution in O(m*(logn)) >> >> On Sat, Aug 20, 2011 at 3:13 PM, Sanjay Rajpal <srn...@gmail.com> wrote: >> >>> Sorry I forgot to mention that. >>> >>> Sanju >>> :) >>> >>> -- >>> 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. >> > > -- > 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.