diff --git a/du6/program.c b/du6/program.c index 4ee51ec..83d9d6b 100644 --- a/du6/program.c +++ b/du6/program.c @@ -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); + + }