0
$\begingroup$

I've not been able to find a precise definition of "stack depth" anywhere and have a rather simple question.

When dealing with trees I'm used to the maximum depth (or height) of the tree being the longest simple path between the root node and a leaf. For instance, if we had a longest simple path of length $n$, there would be $n+1$ nodes involved. In this case the height of the tree (or maximum depth) is $n$.

My question is, for "stack depth" and recursion, do we count the initial call to our procedure and all subsequent calls placed on the stack? Or do we exclude the initial call when counting stack depth?

$\endgroup$
  • $\begingroup$ How much stack space does one simple fn takes that does not do any recursion ? 1 unit or 0 unit $\endgroup$ – Ashish Negi Apr 6 '17 at 14:46
  • $\begingroup$ Clearly a unit of stack space will be consumed by a function that does not do any recursion. But that is not the question. I'm trying to understand if there is a difference between asking, "how many stack frames are on the stack", and "what is the depth of the stack". $\endgroup$ – ClownInTheMoon Apr 6 '17 at 15:10
  • 1
    $\begingroup$ This is vocabulary problem. You can find different meaning in different contexts ; but i think most people will take stack frames as stack depth. $\endgroup$ – Ashish Negi Apr 6 '17 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.