Note: the phrase "the square at M[x, y]
" should be read as an
abbreviation for the phrase "the square area of uniform value having
M[x, y]
as its upper-left corner element".
The design test answer gave an algorithm for finding the largest square area of uniform value in an m-by-n matrix. This algorithm works, but is not as efficient as it could be. In particular, it may
s
, then it isn't necessary to find the
largest square at M[x, y]
if M[x, y]
is within s
elements of
the (right or bottom) edge of the matrix.
For example, if the size of the currently largest square area is 3, then it doesn't make sense to check![]()
M[m - 2, n - 2]
because the largest square
at M[m - 2, n - 2]
can have size of at most 2.
M[x, y]
has size s
then the largest
square at M[x + 1, y + 1]
must have size at least s - 1
(assume
that s
> 1).
For example if the largest square at![]()
M[2, 3]
has size 5, then the
largest square at M[3, 4]
must have size at least 4, and it isn't
necessary to look for squares of size 1, 2, or 3.
square find_largest_square(const int [25][25], int m, int n);
square
is the structure
struct square { int upper_left_x, upper_left_y, size; };
Submit your test files using the command
/export/home/us/csfac/cs176-summer2001/bin/submit-lab-test
your-files-here
where your-files-here are a list of the source files you've written for
the test (your shell may let you abbreviate the command as
~csfac/cs176-summer2001/bin/submit-lab-test
). You should
get an e-mail response back in a few minutes. submit-lab-test
is
available from any linux system.
Make sure you submit something by the deadline. Unlike your programming assignments, you will not be able to submit you lab test after the 12:15 p.m. deadline.
This page last modified on 13 July 2001.