class BTree
{
public:
struct Node
{
int _val;
Node * _lChild;
Node * _rChild;
Node * _pParent;
};
int MaxLength();
int MaxLength(BTree::Node * node, int & maxLen);
}
int BTree::MaxLength()
{
int maxLen =0;
MaxLength(_pRoot,maxLen);
return maxLen;
}
int BTree::MaxLength(BTree::Node * node, int & maxLen)
{
if(node==0)
return 0;
int l = Height(node->_lChild);
int r = Height(node->_rChild);
if(maxLen<(l+r))
maxLen = l+r;
return 1 + max(l,r);
}