Open wsfy15 opened 5 years ago
void delete_tree(node **tree) { if ((*tree)->left != NULL) { delete_tree(&(*tree)->left); } if ((*tree)->right != NULL) { delete_tree(&(*tree)->right); } // At this point, (*tree)->left = NULL && (*tree)->right == NULL. Right? if ((*tree) != NULL) { if ((*tree)->parent != NULL && (*tree)->left == NULL) { (*tree)->parent->left = NULL; free(*tree); } else if ((*tree)->parent != NULL && (*tree)->right == NULL) { // no chance enter here (*tree)->parent->right = NULL; free(*tree); } else if ((*tree)->right == NULL && (*tree)->left == NULL) { free(*tree); (*tree) = NULL; } } return; }
I think that (*tree)->parent->right = NULL; has no chance to execute. I wonder if you can explain it to me. Thank you!
(*tree)->parent->right = NULL;
I think that
(*tree)->parent->right = NULL;
has no chance to execute. I wonder if you can explain it to me. Thank you!