だから私は二分探索木のノード数を取得する方法に取り組んでいます、私が3つのノードを持っているとき、それは私に3を与えます、しかし私が5をするとそれは私に4を与えます、私は何を変える必要がありますか?
int BinaryTree::size(int count, Node *leaf) const
{
if(leaf != NULL)//if we are not at a leaf
{
size(count + 1, leaf->getLeft());//recurisvly call the function and increment the count
size(count + 1, leaf->getRight());
}
else
{
return count;//return the count
}
}