About Me

Sunday, April 29, 2012

Find the kth smallest element in a (MxN) matrix.

PS:Think how efficiently u can do same for an array .

3 comments:

  1. We can use an auxiliary array.. we can copy all the elements of the mxn matrix to that auxiliary linear array and apply quick select algorithm.. complexity would be O(mxn)..

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. -Convert the input matrix(m*n) in to Yongify matrix [Sorted rows and colums)
    - Apply Youngify 'k' times

    Time Complexity: O(mnlogn) + O(mnlogm) + O(k*(m+n))

    ReplyDelete

Hi thanks , we will get back to you shortly !!!