next up previous
Next: Moor: representation of a Up: Unit 11 Previous: Number of activations in

Example: traversal of a moor

Consider a moor constituted by R x C square zones (for given R and C), each of which is either a land zone (which can be crossed) or a water zone (which cannot be crossed). Each zone of the moor is identified by a pair of coordinates < r, c >, with 0 < = r < R and 0 < = c < C. We say that r represents the row and c the column of the zone < r, c >. A traversal is a path across the moor, i.e., a sequence of adjacent land zones that cross the moor from left (column 0) to right (column C - 1). We are interested in traversals in which at each step we move to the right, i.e., from a zone in column c we move to a zone in column c + 1. In other words, the zone in position < r, c > is considered adjacent to the zones in position < r - 1, c + 1 >, < r, c + 1 > and < r + 1, c + 1 >, as shown in the following figure.

\epsfig{file=figures/fig-11-04-palude.pstex}

In the following figure, the character '*' represents a land zone, while the character 'o' represents a water zone. Moor 1 has no traversal, while moor 2 has a traversal (shown in the figure).

% for latex2html
\tt
\begin{tabular}{c\vert cccccc\vert}
\multicolumn{1}{c}{} & ...
...c}{}\\
\multicolumn{1}{c}{} & \multicolumn{6}{c}{\textrm{Moor~2}}
\end{tabular}

We want to check the existence of at least one traversal, and print it out, if it exists (if there is more than one traversal, it is sufficient to print out the first one that we find).


next up previous
Next: Moor: representation of a Up: Unit 11 Previous: Number of activations in