working on bintree
This commit is contained in:
parent
74fdcf500f
commit
3a078e9dea
13
bintree.c
13
bintree.c
@ -26,7 +26,18 @@ void *nextTreeData(TreeNode *root)
|
|||||||
// Releases all memory resources (including data copies).
|
// Releases all memory resources (including data copies).
|
||||||
void clearTree(TreeNode *root)
|
void clearTree(TreeNode *root)
|
||||||
{
|
{
|
||||||
|
if(root->right)
|
||||||
|
clearTree(root->right);
|
||||||
|
else if (root->left)
|
||||||
|
clearTree(root->left);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
root->data = 0;
|
||||||
|
free(root->data);
|
||||||
|
free(root->right);
|
||||||
|
free(root->left);
|
||||||
|
free(root);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the number of entries in the tree given by root.
|
// Returns the number of entries in the tree given by root.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user