Skip to content

Instantly share code, notes, and snippets.

/.cpp

Created June 18, 2017 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5f0faf2b651eccc35ef8307ed9f23d3f to your computer and use it in GitHub Desktop.
Save anonymous/5f0faf2b651eccc35ef8307ed9f23d3f to your computer and use it in GitHub Desktop.
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