|
![](/i/fill.gif) |
Darren New <dne### [at] san rr com> 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
|
![](/i/fill.gif) |