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 23:24

>>39
Brilliant! I'll just deliver an error message when users attempt to open files over 640kB in size, even though they have 8GB of memory.
What the fuck dude, nice strawman. I am talking about safety-critical software here. I never said you should obey these guidelines for your fucking word processor. But you should absolutely obey a similar set of guidelines to land a plane. Simply hoping you've reserved enough stack space for your recursion in that scenario is insanity.

Name: !iN.MY.aRMs 2010-02-10 5:46

recursion for gomosexualistos

any recursion programm my be overwriten without recursion with saving a memory

Name: Anonymous 2010-02-10 11:41

>>41
So you use a language designed for recursion that doesn't increase stack requirements with each function call.

Name: Anonymous 2010-02-10 12:01

>>43
Surely nothing like this can exist!!!

Name: Anonymous 2010-02-10 12:11

FORTRAN 77 doesn't have recursion.  Is FORTRAN 77 a bad language?

Name: !iN.MY.aRMs 2010-02-10 13:59

>>45
FORTRAN77 the best language

Name: Anonymous 2010-02-10 20:22

>>43
No. In such languages, only tail recursion doesn't increase stack requirements, and in this case the language isn't giving you much because you could easily convert it to a looping function by hand.

The idea that Scheme makes any recursion magically better is false, and the practical difference between a tail-recursive function and a looping one is insignificant; consider it a little syntactic sugar. Scheme is a particularly bad choice for safety-critical code because you can't reliably reason about its performance characteristics.

Name: Anonymous 2010-02-10 20:43

the language isn't giving you much because you could easily convert it to a looping function by hand
Yes rewriting code and maintaining clarity is trivial.

Name: Anonymous 2010-02-10 23:24

>>41
I am talking about safety-critical software here.
Precisely. I wasn't going to point it out and let to try to dodge.

Name: Anonymous 2010-02-11 1:05

>>47
Of course you can. Just print out a function trace :D

Name: Anonymous 2010-02-11 2:07

Recursion FAIL
Regress to /b/, please.

Name: Anonymous 2011-02-04 13:51

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