This commit is contained in:
Maryna Kravtsova 2020-11-22 15:29:37 +01:00
parent 64638d2367
commit 32fcfc916a

View File

@ -77,7 +77,7 @@ struct tree* find_minimum(struct tree *root){
struct tree* destroy_tree(struct tree* root){ struct tree* destroy_tree(struct tree* root){
if(root == NULL) return; if(root == NULL) return;
if(root->left == NULL && root->right == NULL){ /*if(root->left == NULL && root->right == NULL){
free(root); free(root);
return NULL; return NULL;
} }
@ -95,7 +95,7 @@ struct tree* destroy_tree(struct tree* root){
struct tree* this = find_minimum(root->left); struct tree* this = find_minimum(root->left);
strcpy(root->value, this->value); strcpy(root->value, this->value);
root->right = destroy_tree(root->right); root->right = destroy_tree(root->right);
} }*/
root->left = destroy_tree(root->left); root->left = destroy_tree(root->left);
root->right = destroy_tree(root->right); root->right = destroy_tree(root->right);
free(root); free(root);