I have a binary search tree in which I created a function that should return the number of nodes that have both children (dir and esq fields other than NULL), but my function does not give the expected value.
The insertion order is as follows: 3,5,2,4,7,0,2,8,7,9 In my view, it should return 4, but it is only returning the value 3.
int getLeafCount(ArvBinaria *a){
if(a == NULL)
return 0;
else if (a->sae != NULL && a->sad!=NULL)
return 1 + getLeafCount(a->sae)+ getLeafCount(a->sad);
}