id we see the pattern then we can easily find that the kth smallest element lie on the upper half of the k*k submatrix(on the upperleft corner ) we can do search on (k*k)/2 elements to find that
On Mon, Oct 10, 2011 at 10:36 AM, Dave <[email protected]> wrote: > @Shubham: So if the matrix is > 1 2 > 3 4 > and you want the 2nd smallest, are you saying that it is 4? > > Dave > > On Oct 9, 7:40 pm, shubham goyal <[email protected]> wrote: > > im assuming it be a square matrix > > then kth smallest element will be in a first k*k sub matrix. > > jst look for smallest element in the diagonal of this matrix. > > it will give the kth smallest element . > > > > > > > > On Mon, Oct 10, 2011 at 4:45 AM, Ankur Garg <[email protected]> > wrote: > > > Given a 2D matrix which is both row wise and column wise sorted. > Propose an > > > algorithm for finding the kth smallest element in it in least time > > > complexity > > > > > A General Max Heap can be used with k space and n+klogk complexity > > > > > Any other solution or even a way by which we dont scan the whole > matrix to > > > find the solution ? > > > > > I > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Algorithm Geeks" group. > > > To post to this group, send email to [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]. > > > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
