The function "terminal_count()" counts the number of leaf nodes of a binary tree.
int terminal_count(struct node *t)
{
static int count = 0;
if((t -> Llink == NULL) && (t -> Rlink == NULL))
return 1;
else
count = count + terminal_count(t -> Llink) + terminal_count(t -> Rlink);
return count;
}
Written by Munia Balayil
awesome program...small and precise...use of recursive function is beautifully done!!
ReplyDelete