generated from freudenreichan/info2Praktikum-DobleSpiel
treeSize implementiert
This commit is contained in:
@@ -90,5 +90,10 @@ 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)
|
||||||
|
{
|
||||||
|
return numNodes;
|
||||||
|
}
|
||||||
|
return 1 + treeSize(root->left) + treeSize(root->right); //1, weil eine Wurzel gefunden wurde und dann immer plus eins fuer einen Teilbaum
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user