Write a function that counts the number of half nodes (nodes with only one child) in the binary tree without using recursion.


Difficulty level
This exercise is mostly suitable for students
int half_nodes(Btree B)
{
    if(!B) return 0;
    if(B->left && !B->right || !B->left && B->right)
        return 1+ half_nodes(B->left) +  half_nodes(B->right) ;
    return half_nodes(B->left) +  half_nodes(B->right) ;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Delete from a table based on hash coalesced with separated zones