implemented treeSize function

This commit is contained in:
Jonas Stamm 2025-12-08 13:32:49 +01:00
parent db26d7529e
commit f42969c699

View File

@ -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
}