Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AdvancedLevel_C++/1159. Structure of a Binary Tree (30).cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,7 @@ int main() {
}
cout << (flag ? "Yes" : "No") << endl;
}
free(postorder);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resources of tree nodes still not deallocated. Consider std::shared_ptr<TreeNode> instead of raw pointers. Or a tree class with a destructor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote an example: Tree.h
Tree_test.cpp.
The allocated memory pointed to by smart pointers won't be deallocated until they reach their lifespan

free(inorder);
return 0;
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ PAT的这个仓库我一直在维护,包括每次考试后新出的题目都
| 1153 | Decode Registration Card of PAT (25) | [查看题解](https://www.liuchuo.net/archives/8023) | 模拟,排序,map |
| 1154 | Vertex Coloring (25) | [查看题解](https://www.liuchuo.net/archives/8025) | STL的应用,set,hash |
| 1155 | Heap Paths (30) | [查看题解](https://www.liuchuo.net/archives/8027) | 深搜回溯,堆 |
| 1156 | Sexy Primes (20) | [查看题解]() | 水题 |
| 1157 | Anniversary (25) | [查看题解]() | 模拟,set |
| 1158 | Telefraud Detection (25) | [查看题解]() | 模拟,并查集,排序 |
| 1159 | Structure of a Binary Tree (30) | [查看题解]() | 中序后序建树,树的遍历 |
| 1156 | Sexy Primes (20) | [查看题解](./AdvancedLevel_C++/1156.%20Sexy%20Primes%20(20).cpp) | 水题 |
| 1157 | Anniversary (25) | [查看题解](./AdvancedLevel_C++/1157.%20Anniversary%20(25).cpp) | 模拟,set |
| 1158 | Telefraud Detection (25) | [查看题解](./AdvancedLevel_C++/1158.%20Telefraud%20Detection%20(25).cpp) | 模拟,并查集,排序 |
| 1159 | Structure of a Binary Tree (30) | [查看题解](./AdvancedLevel_C++/1159.%20Structure%20of%20a%20Binary%20Tree%20(30).cpp) | 中序后序建树,树的遍历 |

# PAT乙级题解

Expand Down