From 3a078e9dea3490c454ea2fbd6b8d1e03aeff9756 Mon Sep 17 00:00:00 2001 From: kachelto100370 Date: Sun, 7 Dec 2025 13:13:43 +0100 Subject: [PATCH] working on bintree --- bintree.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bintree.c b/bintree.c index 5cf82a9..3933958 100644 --- a/bintree.c +++ b/bintree.c @@ -26,7 +26,18 @@ void *nextTreeData(TreeNode *root) // Releases all memory resources (including data copies). 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.