This commit is contained in:
Maryna Kravtsova 2020-11-22 15:30:34 +01:00
parent 32fcfc916a
commit 83f87f5e94

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);
@ -142,7 +142,7 @@ int main(){
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
printf("%s\n", tree->value); printf("%s\n", tree->value);
tree = search(tree); tree = search(tree);
destroy_tree(tree); tree = destroy_tree(tree);
printf("Koniec\n"); printf("Koniec\n");
return 0; return 0;
} }