From f42969c699986d26bf1b787cf55cae85a0192d83 Mon Sep 17 00:00:00 2001 From: stammjo100588 Date: Mon, 8 Dec 2025 13:32:49 +0100 Subject: [PATCH] implemented treeSize function --- bintree.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bintree.c b/bintree.c index cd4571a..1e34db0 100644 --- a/bintree.c +++ b/bintree.c @@ -189,5 +189,9 @@ void clearTree(TreeNode *root) // Returns the number of entries in the tree given by root. unsigned int treeSize(const TreeNode *root) { - + if (root == NULL) { //0 for end + return 0; + } + return 1u + treeSize(root->left) + treeSize(root->right); //using 1u to insure unsigned + //recursively adds entries in the tree after root to left and right } \ No newline at end of file