I need to create a recursive method that takes as a parameter the root node of a binary search tree. This recursive method will then return the int value of the total number of nodes that have one left descendant.
int Tree::leftPtrCount(int count) {
return leftPtrCountHelper(rootPtr, count);
}
int Tree::leftPtrCountHelper(TreeNode *node, int count){
if (node == NULL)
return 0;
if (node->leftPtr != NULL && node->rightPtr == NULL)
count++;
else
return leftPtrCountHelper(node->leftPtr, count) + leftPtrCountHelper(node->rightPtr, count);
}