POV-Ray : Newsgroups : povray.off-topic : Teach yourself C++ in 21 days : Re: Days 5- Server Time
29 Jul 2024 12:23:05 EDT (-0400)
  Re: Days 5-  
From: Warp
Date: 26 Apr 2012 08:09:56
Message: <4f993b14@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> If you can limit the recursion a priori, then sure. If you know you'll only 
> have at most 4 levels of tree, or only 128 entries in the list to sort, or 
> something like that, recursion is fine. I wouldn't write production code to 
> manipulate an arbitrary data structure with actual machine-stack-based 
> recursion in C.

  Very usually the recursion depth of a typical recursive algorithm is
O(log n). This means that the computer wouldn't be able to hold as much
data as to make you run out of stack space when running the recursive
algorithm on it. (For example, if the recursion depth is 50, that means
that there's about 10^15 elements of data. Even if each element took just
one single byte, that would be like 1024 terabytes of RAM.)

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.