Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Recursion FAIL

Name: Anonymous 2010-02-08 22:29

I'm learning to hate recursion terribly, but I need to do it for this project.
The point of the project is to go from pointA to pointB using recursion in java. And print out all paths.
my input is
5
3 0
1 3

output should be about 10 paths in form of (col,row)
can I get a few pointers and maybe a little help?
private void pathFinder(int row, int col, int xB, int yB, int[][] array)
{
    if(row==xB && col==yB)
    {
        System.out.println("("+row+","+col+") ");
    }
    if(canIGoNorth(row,xB)==true)
    {
        System.out.print("("+row+","+col+") ");           
        pathFinder(row-1,col,xB,yB,array);
        System.out.print("("+row+","+col+") ");
    }
    if(canIGoEast(col,yB)==true)
    {
        System.out.print("("+row+","+col+") ");           
        pathFinder(row,col+1,xB,yB,array);
        System.out.print("("+row+","+col+") ");
           
    }
       
       
    }
inb4 learn to code, everythings wrong, and java sucks.

Name: Anonymous 2010-02-09 0:16

>>6
These standards, written by NASA/JPL engineers: http://spinroot.com/p10/

The very first rule abolishes recursion of any kind, direct or indirect. The rules also abolish dynamic memory allocation, so no, you can't emulate the stack yourself. The whole idea is to be able to statically calculate and prove upper bounds on stack space, memory usage, and processor instructions required to complete an operation.

Give me an example of a problem which can't be solved without recursion.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List