For program #5, the basic recursive idea is given by the following
algorithm that you must implement:
// Private recursive routine
ArrayList getLongestSequence( Position startingSquare )
{
ArrayList result = new ArrayList( );
for each Position p that is adjacent to startingSquare AND has a large value )
{
recursively compute the longest sequence starting at p
and if this sequence is longer than the one in result,
update result
}
add startingSquare to result
return result;
}
// Public driver
ArrayList getLongestSequence( int [ ] [ ] matrix )
{
Construct a Position object for each position in the matrix
call the recursive routine for each Position
use the largest ArrayList returned by any of the recursive calls.
}