0
I have a binary search tree in which I created a function that should return the amount of nodes that have both children (different dir and Esq NULL fields), but my function does not give the expected value.
The order of insertion is as follows: 3,5,2,4,7,0,2,8,7,9 In my view, should return 4, but 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);
}
How does the tree behave in relation to repetitions ? Both the
2
like the7
has repetitions– Isac
Depending on the implementation, you can’t tell if the problem is there or elsewhere, or if, based on your algorithm, your interpretation is wrong.
– Maniero
I looked here and really the repetition influences, without it the implementation works. For the case that I am working is enough, but I will try to leave in a way that accepts the repetition, vlw
– Rhuan