Hello,I have an assignment question and I cant understand it properly.Can anyone of you help me?Here is the question...
An N x N square consists of black and white cells arranged in a certain way. The problem
is to determine the number of white areas and the number of white cells in each area. For
example a regular 8 x 8 chess board has 32 one-cell white areas, similarly consider the
following two 5 x 5 boards have 3 and 4 white areas respectively each of size 4 white
cells.
b b w w b
b b w w b
b b b b b
w w b w w
w w b w w
w w b w w
w w b w w
b b b b b
w w b w w
w w b w w
Write a program that, for a give N x N square(Array), outputs the number of white areas
and their sizes. Use an N+2 x N+2 array with properly marked cells. Two additional rows
and columns constitute a frame of black cells surrounding the entered square to simplify
your implementation. For example the given left hand side (LHS) square is store in the
right hand side (RHS) array:
(LHS)
b b w w b
b b w w b
b b b b b
w w b w w
w w b w w
(RHS)
b b b b b b b
b w w b w w b
b w w b w w b
b b b b b b b
b w w b w w b
b w w b w w b
b b b b b b b
Hint: Traverse the square row by row and, for the first unvisited cell encountered invoke
a function call that process one area. The secret is in using four recursive calls in this
function for each unvisited white cell and marking it with a special symbol as visited
(counted).
Is there any nested loops neede to traverse row by row,or the backtracking will solve it?