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

2D dynamic bool array?

Name: Anonymous 2006-01-03 16:44

I want to create a 2D dynamic bool array (or char is fine too). I'm doing the n-queens problem and I've figured everything out except for this part. Any help?

Name: Anonymous 2006-01-10 12:05

Now, to explain tail recursion. Tail recursion is possible whenever the last thing a function does is call itself. Simple as that. That is all you need to know if you want to use it.

For example, in this code of yours
int distance(int a, int b)
{
    if(a==b)
        return 0;
    else
        return (cities[b-1] + distance(a, b-1));
}
the last thing that happens is not a function call, but an addition.

The compiler will most likely rewrite and optimize this to use tail recursion anyway. And finally, the compiler will optimize any tail recursion to become something closer to a for/while loop. But teachers generally do not like arguments like "the compiler is clever and makes up for my cluelessness", so you should favor iteration instead of recursion in your C code.

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