(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 Fri Dec 17 12:03:06 2004.
HTML page formatted Wed Oct 26 09:47:21 2005.
Cite this as:
Paul E. Black, "collective recursion", from
Dictionary of Algorithms and Data
Structures, Paul E. Black, ed.,
NIST.
http://www.nist.gov/dads/HTML/collectrecur.html