Question: In Java, Given an array (m x n) of positive integers, find, in (mn) time, the maximum size square submatrix such that all values of

In Java, Given an array (m x n) of positive integers, find, in (mn) time, the maximum size square submatrix such that all values of the submatrix are larger than a given input k. For example, consider the following matrix

82 10 16 15 66

91 28 98 43 4

13 55 96 92 85

92 96 49 80 94

64 97 81 96 68

When k=3, the maximum submatrix is the entire matrix.

When k = 10, the maximum submatrix size is 4x4 with with (5,4)-th entry being the bottom right corner.

When k = 20, the maximum submatrix size is 3x3. There are three such submatrices whose bottom right corner coordinates are (4,4), (5,4), and (5,5), respectively.

When k = 50, the maximum submatrix size is 2x2. There are three such submatrices whose bottom right corner coordinates are (4,5), (5,2), and (5,5), respectively.

When k = 70, the maximum submatrix size is 2x2 with (4,5) being its bottom right corner coordinates.

Input: a text file of the integer matrix as in the above example, and a value k given by a user using the keyboard.

Output: the size of the maximum submatrix and the coordinates of the bottom right corner(s). In the above example for k=20, the output would be

3

4 4

5 4

5 5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!