[Tutor] Re: Recursion....what are the best situations to use it?
jfouhy at paradise.net.nz
Sat Apr 16 00:06:52 CEST 2005
> Recursion is dangerous if its depth is unchecked. I've recently seen a recursive
> quicksort implementation run wild for example, killing the program without any
> error message (not in Python, but the principle is the same regardless the
> programming language).
I recall an assignment I once had for an algorithms course --- I think
it was to implement and analyse Strassen's algorithm.
My recursive algorithm would run out of stack space when the input
matrices got too large. But I was programming in Java, and the JVM
allows you to set the stack size.
So, by plotting input size when it crashes vs stack size, I was able to
get a nice graph displaying the space complexity of the algorithm :-)
More information about the Tutor