Free memory after removing

a node from a LinkedList or TreeNode.
This commit is contained in:
Yudong Jin
2023-01-02 19:53:55 +08:00
parent 6b02449f22
commit 410c5d6b62
20 changed files with 69 additions and 140 deletions

View File

@ -33,6 +33,7 @@ int main() {
PrintUtil::printTree(n1);
// 删除结点 P
n1->left = n2;
delete P; // 释放内存
cout << endl << "删除结点 P 后\n" << endl;
PrintUtil::printTree(n1);