generated from freudenreichan/info2Praktikum-DobleSpiel
implemented treeSize function
This commit is contained in:
parent
db26d7529e
commit
f42969c699
@ -189,5 +189,9 @@ void clearTree(TreeNode *root)
|
|||||||
// Returns the number of entries in the tree given by root.
|
// Returns the number of entries in the tree given by root.
|
||||||
unsigned int treeSize(const TreeNode *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
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user