I need to do a non-recursive function for count the leafs in a tree. I have the recursive algorithm, Can someone help me to figure this out!!
count leafs
int count_Lnodes(root, int cnt)
{
if (root != NULL)
{
cnt = count_Lnodes(root->left, cnt);
cnt = count_Lnodes(root->right, cnt);
if (root->left == NULL && root->right == NULL) ++cnt;
}
return cnt;
}