Purchase Solution

C++ program to find a biggest zero submatrix

Not what you're looking for?

Ask Custom Question

Write a C++ program to accept an n*m matrix containing only 0 and 1 values, and then find it's biggest zero submatrix i.e. the biggest submatrix in which all the values are 0.

INPUT

First line contains two numbers n, m (n,m<=300),
then n lines, each having m 0/1 digits.

OUTPUT

One number, which represent the number of zeros inside the biggest zero submatrix.

SAMPLE INPUT

6 5
0 0 0 0 0
0 1 1 1 0
0 1 0 1 0
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0

SAMPLE OUTPUT

10

Purchase this Solution

Solution Summary

Solution implements a brute force logic using recursion that redundantly evaluates many submatrices multiple times. Code compiles error and warning free with "g++ -Wall -ansi" (g++ version 3.3.1 on cygwin) and has been tested for execution with given sample input as well as various base case permutations of 1x1 and 2x2 matrices.

Solution Preview

Attached 154009.cpp provides one of the ways to solve this problem by evaluating all the sub-matrices of user input matrix for the ...

Purchase this Solution


Free BrainMass Quizzes
C++ Operators

This quiz tests a student's knowledge about C++ operators.

C# variables and classes

This quiz contains questions about C# classes and variables.

Basic Networking Questions

This quiz consists of some basic networking questions.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.