Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Maximum square submatrix. Given an n -by- n matrix of 0s and 1s, find a contiguous square submatrix of maximum size that contains only 1s.

  1. Maximum square submatrix. Given an n-by-n matrix of 0s and 1s, find a contiguous square submatrix of maximum size that contains only 1s. To do so, organize your program according to the following public API:

    public class MaximumSquareSubmatrix { // Returns the size of the largest contiguous square submatrix // of a[][] containing only 1s. public static int size(int[][] a) // Reads an n-by-n matrix of 0s and 1s from standard input // and prints the size of the largest contiguous square submatrix // containing only 1s. public static void main(String[] args) } 

    Here is some more information about the required behavior:

    • Size. The size of a square submatrix is its number of rows (or columns). You may assume that argument to the size() method is a square matrix containing only 0s and 1s.

    • Contiguous. The square submatrix must be contiguousthe row indicies must be consecutive and the column indices must be consecutive.

    • Performance. The size() method should take time proportional to n2n2 in the worst case. Significant partial credit for solutions that take time proportional to n3n3 or n4n4.

    • Input format. Standard input will contain a positive integer n, followed by n lines, with each line containing n 0s and 1s, separated by whitespace.

    Here are a few sample executions:

    ~/Desktop/performance> cat square6.txt 6 0 1 1 0 1 1 1 1 0 1 0 1 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 0 0 0 1 1 ~/Desktop/performance> java-introcs MaximumSquareSubmatrix  3 ~/Desktop/performance> cat square7.txt 7 0 1 1 0 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 ~/Desktop/performance> java-introcs MaximumSquareSubmatrix  4 

    The maximum square submatrix problem is related to problems that arise in databases, image processing, and maximum likelihood estimation. It is also a popular technical job interview question.

image text in transcribed
3. Maximum square submatrix. Given an nbyn matrix of 0s and 1s, find a contiguous square submatrix of maximum size that contains only 1s. To do so, organize your program according to the following public API: Here is some more information about the required behavior: - Size. The size of a square submatrix is its number of rows (or columns). You may assume that argument to the size() method is a square matrix containing only 0s and 1s. - Contiguous. The square submatrix must be contiguous - the row indicies must be consecutive and the column indices must be consecutive. Performance. The size () method should take time proportional to n2 in the worst case. Significant partial credit for solutions that take time proportional to n3 or n4. - Input format. Standard input will contain a positive integer n, followed by n lines, with each line containing n0 s and Is, separated by whitespace. Here are a few sample executions: The maximum square submatrix problem is related to problems that arise in databases, image processing and maximan likelihood estimation. It is also a popular technical job intenviev

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions

Question

Find the exact value of expression. sec sin 2.

Answered: 1 week ago

Question

What do you mean by dual mode operation?

Answered: 1 week ago

Question

Explain the difference between `==` and `===` in JavaScript.

Answered: 1 week ago