-
-
Save anonymous/5f0faf2b651eccc35ef8307ed9f23d3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int countNodes(){ | |
int count = 0; | |
return getNodeCount(root, count); | |
} | |
int BinTree::getNodeCount(TreeNode *nodePtr, int nodeCount) { | |
//int nodeCount = 0; | |
if (nodePtr) { | |
nodeCount++; | |
getNodeCount(nodePtr->left, nodeCount); | |
getNodeCount(nodePtr->right, nodeCount); | |
return nodeCount; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment