Content deleted Content added
Quuxplusone (talk | contribs) massive cleanup, rewrite examples, rm lots of redundancy; but it still needs a major rewrite |
→Tail-recursive functions: fix example's wrong return type and infinite recursing |
||
Line 111:
Notice that a single function may be both tail-recursive and augmenting recursive, such as this function to count the odd integers in a linked list:
{
if (head == NULL)
return 0;
if (head->data % 2 == 1)
return count_odds(head->next) + 1; /* augmenting recursion */
return count_odds(head->next); /* tail recursion */
}
|