Hi..

I got trouble here.
I got this section of code that I am trying to return the total number
of nodes with only one child.



template<class elemType>
int binaryTreeType<elemType>::sCCount(nodeType<elemType> *p)
{
        if ( p == NULL )
                return 0;
        else
                if ((p->llink == NULL && p->rlink != NULL) || (p->llink != NULL 
&&
p->rlink == NULL))
                        return 1;

                else
                        return sCCount(p->llink) + sCCount(p->rlink);
}

There are a total of 4 nodes with only 1 child, but the function is
only returning 2.

Any ideas?

Thanks


Reply via email to