views:

59

answers:

3

I'm working on a java assignment for a class and I'm unsure how to solve this problem. I don't want it completed for me, but get me started in the right direction. I'm mostly unsure of the recursive part of the program. I'm not very good at programming.

problem:

NorthEast paths are obtained from a two-dimensional grid by moving up and right. For example, in the figure below, there are two paths from 1,0 to 0,1. The first is (1,0), (0,0), (0,1), the second is (1,0), (1,1), (0,1). Note that there are no NorthEast paths from (0,1) to any other point. Also note that there is one NorthEast path from (1,1) to (0,1). You are to write a program that takes a number (size of grid - no larger than 10) and a starting location and an ending location and recursively computes all of the "NorthEast" paths.

0,0 0,1

1,0 1,1

I'm reading in the file prog2.dat

which reads in the grid size first and then the starting coordinates and then finishing coordinates. for example:

5

3 0

1 3

It needs to be one files, so I'm going to use methods. If someone could get me started or direct me to a similar question already posted, I would appreciate it.

A: 

This may help:

http://en.wikipedia.org/wiki/Binomial_theorem

finnw
A: 

Start by reading about Pascal's Triangle.

For a given starting location (x0, y0), and a given ending location (x1, y1), and restricting yourself to moving North or East on a grid, a minimum-length path will consist of precisely (x1-x0) steps to the East and (y1-y0) steps to the North, in some order.

John R. Strohm
A: 
SB