In developing a recursive solution, consider the base cases first. What situation(s) cause the recursive method to exit?
-
We have arrived at a location that is off the data structure. It is important to catch this situation first to avoid an array indexing error.
-
Encountering a '*' character means that we have run into a wall. The algorithm should stop.
-
Encountering a location we have already visited should cause the algorithm to stop.
-
Arriving at a location that has a row or column value equal to 1 or MAXROW
or MAXCOL
means that we have found an exit point.