>Sure, in theory each recursive level can make calls to the next level multiple times sequentially without eating calling levels because the previous down level call returns before the next down level call is issued. This renders 2 levels to the caller - callee relationship. Now we have 32 levels of caller to calle possibilities, therefore 2 (the caller-callee relation) ^ 32(the number of caller-callee relations allowed) possible levels of recursion.
I believe that this concept applies best to situations where one is predicting computational effort when dividing (splitting) a list into 2 parts. For example, the QuickSort algorithm and binary tree search algorithm are two cases where the # of required comparisons is proportional to LOG2(N). But there are other uses of recursion where this model doesn't hold as neatly. For example, the algorithm for converting infix to postfix: The parser will fail using recursion in VFP if the expression happens to have 32 nested levels of parenthesized expressions (OK, not likely, but has nothing to do with 2^32). Likewise for any tree-type of data structure that might have 32 or more levels: in a worst-case situation (i.e., very unbalanced tree) you can/will recurse beyond VFP's recursion limit.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement