You cannot find the matrix n x nin ntime. Counterexample: matrix of zeros with one element set to unity. You must check each item to find where it is, so the time should be at least O(n^2).
Now, if you say that there are n= entries in the matrix n^2, and you only look at the submatrices that form a continuous block, then you should be able to find the largest submatrix by walking diagonally along the matrix, tracking each rectangle as you go. In the general case, you could have up O(sqrt(N))rectangles at the same time, and you would need to look in them to find out which rectangle was the largest, so you should be able to do this in O(N^(3/2) * log(N))time.
If you can select arbitrary rows and columns to form your submatrix, then I do not see any obvious polynomial time algorithm.
source
share