Problem:

Consider a network of streets laid out in a rectangular grid, there is no negative value, the smallest point is (0,0). For example see image.

In a northeast path from one point in the grid to another, one may walk ONLY to the north (top) and to the east (right). For example, there are four northeast paths from A to B in the preceding grid: see image.

Write a program that uses one or two recursive functions to

1) count the number of northeast paths from one point to another (user could input the values) in a rectangular grid, and
2) print out all the paths like:

For example, there are 4 paths from (0,1) to (3,2)
(0,1) (0,2) (1,2) (2,2) (3,2)
(0,1) (1,1) (1,2) (2,2) (3,2)
(0,1) (1,1) (2,1) (2,2) (3,2)
(0,1) (1,1) (2,1) (3,1) (3,2)

Hint:

There are mainly two parts you need to design for this project

  • The total number of the paths, you should use a recursive method to calculate that.
  • To print each individual path, you should have another recursive method design to do this part, and one approach is to have an argument as string to record every step and finally to print it.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.