one of the possible methods is to use concept same as EXTRACT-MIN of heaps do the following steps *m*n *times 1. print a[0][0] ans replace this by a[m-1][n-1] 2. call REORDER(0,0)
in REORDER(i,j) function we perform following operations to make array's all row's and column's sorted 1.if a[i,j] <= a[i+1][j] && a[i,j] <= a[i][j+1], its done else swap with min a[i+1,j] and a[i,j+1] and keep going in same way ans also boundary checks are also important... TC: O(mn(m+n)) SC: O(1) -- 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.