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 = 0;
|
||||
if(tree == NULL){
|
||||
return count;
|
||||
if(tree == NULL || (tree->left == NULL && tree->right == NULL)){
|
||||
return 0;
|
||||
}
|
||||
if(tree->left && tree->right){
|
||||
return count + count_leaves(tree->left) + count_leaves(tree->right);
|
||||
|
||||
}
|
||||
return count+1;
|
||||
return 1+ count_non_leaves(tree->left) + count_non_leaves(tree->right);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user