Image

Imagevorpal wrote in Imagecpp relief

Listens: Modest Mouse - The Lonesome Crowded West album

Recursive vs. non-recursive?

As mentioned in my previous post, I'm writing a program with a method that is extremely recursive (i.e. it has a for loop inside of it and in each iteration of the for loop, it calls itself - the depth of recursion that I've observed so far has been between 400 and 500, but it could easily go higher for larger problems). I could implement this problem in a non-recursive fashion using an STL stack, but it would be rather difficult and annoying to do so.

My question: would it be worthwhile, in terms of memory or speed? Would overflowing the stack be a problem for higher depths of recursion that could be avoided by a non-recursive solution?

Note: Many thanks to everyone who replied to my last post. I did find a really hard-to-detect memory leak that I think *may* have been causing the problem (although why I wasn't getting a std::bad_alloc exception is beyond me if I was running out of memory, which is highly likely given the nature of the leak). Seems to be working now for a parameter that, beforehand, was guaranteed not to work :D:D:D. Thanks again! *heaves a sigh of relief*

Stupid Schreier-Sims group algorithms *grumble*.