avatar
CS Algo Question# CS - 计算机科学
l*t
1
1. Create a function findZeroArraySize() that takes a 2-dimensions int array
, its width and its height as arguments. The array is filled with 0 and 1. T
he function returns the size (in int) of the biggest 2-dimensions sub-array
filled only with 0. This function should be as fast as possible.
Ex:
If argument is , function returns 9.
001011110
110001100
010000011
110001100
111011100
Thanks a lot.
avatar
c*y
2
return 3吧?

【在 l***t 的大作中提到】
: 1. Create a function findZeroArraySize() that takes a 2-dimensions int array
: , its width and its height as arguments. The array is filled with 0 and 1. T
: he function returns the size (in int) of the biggest 2-dimensions sub-array
: filled only with 0. This function should be as fast as possible.
: Ex:
: If argument is , function returns 9.
: 001011110
: 110001100
: 010000011
: 110001100

avatar
z*n
3
I guess so.

【在 c********y 的大作中提到】
: return 3吧?
avatar
l*t
4
No, it is 9.
the largest 0 sub matrix has 9 zeros :
000
000
000

【在 z*****n 的大作中提到】
: I guess so.
avatar
z*n
5
hehe, got it.

【在 l***t 的大作中提到】
: No, it is 9.
: the largest 0 sub matrix has 9 zeros :
: 000
: 000
: 000

avatar
s*e
6
I think I have an algorithm in mind. Suppose the size of the original matrix
is a * b. The complexity of my algorithm is O(ab). Not very fast ...

【在 l***t 的大作中提到】
: 1. Create a function findZeroArraySize() that takes a 2-dimensions int array
: , its width and its height as arguments. The array is filled with 0 and 1. T
: he function returns the size (in int) of the biggest 2-dimensions sub-array
: filled only with 0. This function should be as fast as possible.
: Ex:
: If argument is , function returns 9.
: 001011110
: 110001100
: 010000011
: 110001100

avatar
a*t
7

There are a*b elements in the matrix. You have to access each at least once.
If your algorithm is O(ab), it is pretty fast, I think.

【在 s******e 的大作中提到】
: I think I have an algorithm in mind. Suppose the size of the original matrix
: is a * b. The complexity of my algorithm is O(ab). Not very fast ...

avatar
g*a
8
当年我们的算法作业题啊

【在 s******e 的大作中提到】
: I think I have an algorithm in mind. Suppose the size of the original matrix
: is a * b. The complexity of my algorithm is O(ab). Not very fast ...

avatar
m*h
9
I think it can be solved by scanning the matrix column by column while
maintaning a measure, say, T(i), which is the maximum all 0 sub matirx before
scanning to column i, and then update T(i). The complexity should be
O(ab).

array
T
sub-array

【在 s******e 的大作中提到】
: I think I have an algorithm in mind. Suppose the size of the original matrix
: is a * b. The complexity of my algorithm is O(ab). Not very fast ...

avatar
a*t
10

How can you gaurantee the solution in T(i) is the largest?
1111001111
1110000111
1100000011
1000000001
0000000000
1000000001
.......

【在 m****h 的大作中提到】
: I think it can be solved by scanning the matrix column by column while
: maintaning a measure, say, T(i), which is the maximum all 0 sub matirx before
: scanning to column i, and then update T(i). The complexity should be
: O(ab).
:
: array
: T
: sub-array

avatar
s*v
11
O(n*n*n)
avatar
a*t
12
Where did you find these problems? homework?
These problems are listed at
http://trikuare.cx/mt/archives/000718.php

【在 l***t 的大作中提到】
: 1. Create a function findZeroArraySize() that takes a 2-dimensions int array
: , its width and its height as arguments. The array is filled with 0 and 1. T
: he function returns the size (in int) of the biggest 2-dimensions sub-array
: filled only with 0. This function should be as fast as possible.
: Ex:
: If argument is , function returns 9.
: 001011110
: 110001100
: 010000011
: 110001100

avatar
m*h
13
It's like induction. It is simple when scanning the first column. Then, in the
folowing steps, we need only check the new column, to see if T(i) can be made
any larger.

before
matrix

【在 a******t 的大作中提到】
: Where did you find these problems? homework?
: These problems are listed at
: http://trikuare.cx/mt/archives/000718.php

avatar
S*t
14
i think these are all basic programming problems
once i was participating ACM/ICPC, i could solve
these 3 problem in 5 min

【在 a******t 的大作中提到】
: Where did you find these problems? homework?
: These problems are listed at
: http://trikuare.cx/mt/archives/000718.php

avatar
a*t
15
If these are homework problems, the instructor is too lazy. That's the point.

【在 S*******t 的大作中提到】
: i think these are all basic programming problems
: once i was participating ACM/ICPC, i could solve
: these 3 problem in 5 min

avatar
S*t
16
re
but maybe that guy is just interested in programming, hehe

【在 a******t 的大作中提到】
: If these are homework problems, the instructor is too lazy. That's the point.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。