二叉树的基本操作:
例子:
源码:
size_t _Depth(Node* root)
{
if (NULL == root)
{
return 0;
}
if (NULL == root->_left && NULL == root->_right)
{
return 1;
}
size_t leftDepth = _Depth(root->_left);
size_t rightDepth = _Depth(root->_right);
return leftDepth > rightDepth ? leftDepth + 1 : rightDepth + 1;
}