|
|
"Recursion is usually also considerably slower than doing it iteratively."
Going a bit off-topic here, but this affirmation is true if slightly
misleading -- recursive programming is often slower than iterative
programming, but unless there's a serious bug involved they're always the
same order, whether you recourse or iterate. That is, if you have an
iterative function that has an execution time of A*(input dimension) for
some constant A, then the recursive version will be B*(input dimension) with
B > A (both linear, but recursion time growing quicker), as opposed to, say
B*(input dimension)^2 (the recursive version being showing quadratic growth
instead of linear).
"While it's proven that certain algorithms can only be done recursively"
Quicksort is a case, if I'm not mistaken. In fact I think it's thought of as
massively recursive, whatever that means
"Warp" <war### [at] tagpovrayorg> wrote in message
news:4084e27b@news.povray.org...
> Recursive function calls are a burden in practically all programming
> languages because they have quite a lot of overhead (the exception
> being the tail recursion optimization in some languages when the
> recursive call is made properly). Recursion is usually also considerably
> slower than doing it iteratively.
>
> While it's proven that certain algorithms can only be done recursively
> (ie. using a recursion stack) and cannot be done iteratively, you should
> still try.
> If you need a stack, then you'll have to use an array. The problem is,
> of course, that arrays are fixed in size (ok, you can increase the
> size of an array by creating a bigger array and copying the contents
> of the old one to the new one, but that's some overhead as well).
>
> --
> plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
> sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
> density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
> <1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}// - Warp -
Post a reply to this message
|
|