Create a gist now

Instantly share code, notes, and snippets.

anonymous /.cpp
Created Jun 18, 2017

What would you like to do?
template <class T>
int BinTree<T>::getHeight(TreeNode *nodePtr) {
if (!nodePtr)
return 0;
else {
int leftDepth = getHeight(nodePtr->left);
int rightDepth = getHeight(nodePtr->right);
if (leftDepth > rightDepth)
return leftDepth + 1;
else return rightDepth + 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment