Next: Moor: representation of a Up: Unit 10 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.

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).

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: Moor: representation of a Up: Unit 10 Previous: Number of activations in