Create a gist now

Instantly share code, notes, and snippets.

anonymous /.cpp
Created Jun 18, 2017

What would you like to do?
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