wejfw
This commit is contained in:
parent
a8d91996df
commit
a480aa16fe
@ -79,15 +79,13 @@ int count_leaves(struct tree* tree){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int count_non_leaves(struct tree* tree){
|
int count_non_leaves(struct tree* tree){
|
||||||
int count = 0;
|
if(tree == NULL || (tree->left == NULL && tree->right == NULL)){
|
||||||
if(tree == NULL){
|
return 0;
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
if(tree->left && tree->right){
|
|
||||||
return count + count_leaves(tree->left) + count_leaves(tree->right);
|
|
||||||
|
|
||||||
}
|
return 1+ count_non_leaves(tree->left) + count_non_leaves(tree->right);
|
||||||
return count+1;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user