Skip to content

Conversation

@SuYindu
Copy link
Contributor

@SuYindu SuYindu commented May 4, 2019

No description provided.

}
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants