void destroyAux(struct Node* node) { if (node == NULL) return; destroyAux(node->next); //printf("Freeing node with the value of %d\n", node->val); free(node); }
~Tree() { destroyAux(root); }
void destroyAux(TreeNode * parent) { if (!parent) { return; } destroyAux(parent->left); destroyAux(parent->right); delete parent; }
void destroyAux(TreeNode * n) { if (!n) { return; } destroyAux(n->left); destroyAux(n->right); delete n; }
void destroy(List* list) { destroyAux(list->head); }