For Binary search trees or any data structures that are recursive in nature,
you will want to implement a recursive algorithm to solve most of its problems.Its not only easier to write, but its easier to understand as well. So with that said, consider this recursive algorithm that finds the height of a tree.
int BinaryTree:height(){
return _height(this.root);
}
int BinaryTree::_height(const Node* root){
if( isNull( root) ) return 0;
int leftTreeMax = _height(root.getLeft()) + 1; //add one and move down
int rightTreeMax = _height(root.getRight()) + 1; //add one and move down
return std::max(leftTreeMax, rightTreeMax) + 1; //account for the root
}