Tail recursion (87)

35 Name: #!/usr/bin/anonymous : 2006-03-07 14:26 ID:gTAQ7/+t

>>32

So it does use O(N) memory for something that could be done in O(1) with an imperative loop?

I suppose it might be able to optimize something that simple, but what about a slightly more complex recursion? You'll end up having to pray that the compiler will optimize it properly even though you wrote a horribly ineffecient algorithm. Of course, you always have to trust the compiler to some extent to optimize properly, but forcing you to write badly performing code on the algorithmic level, and praying the compiler fixes it, doesn't seem very wise.

This thread has been closed. You cannot post in this thread any longer.