(algorithmic technique)
Definition: A special form of tail recursion, where the results are produced during the recursive calls and nothing is returned. The recursion may be optimized away by executing the call in the current stack frame, rather than creating a new stack frame, or by deallocating the entire recursion stack at once rather than a little at each return.
Note:
The following program prints the values greater than limit in a list. int overlimit(list l, int limit)
At the return, the compiler can deallocate all the memory for the recursion stack at once.
{
if (null == l) {
return;
}
if (limit < head(l)) {
printf("%d\n", head(l));
}
overlimit(tail(l), limit);
}
Author: PEB
If you have suggestions, corrections, or comments, please get in touch with Paul E. Black.
Entry modified 14 August 2008.
HTML page formatted Thu Aug 14 12:18:07 2008.
Cite this as:
Paul E. Black, "collective recursion", in
Dictionary of Algorithms and Data
Structures [online], Paul E. Black, ed.,
U.S. National Institute of
Standards and Technology. 14 August 2008. (accessed TODAY)
Available from: http://www.nist.gov/dads/HTML/collectrecur.html