On DJW Problem 4-23, Counting Paths - 

top of Musings page

By: Nicholas Duchon

I have attached two Flash presentations that I hope help you visualize the recursion in this problem, and help you develop the matrix solution.

The Algorithm (fixed):

int paths (r, c, n)
  if (r == n) return 1 // top row
  if (c == n) return 1 // right column
  return paths (r+1, c, n) + paths (r, c+1, n)

In words:

Links to presentation in Flash: