(1)if(root为空)返回0
(2)lDepth = 左子树深度,rDepth = 右子树深度
(3)depth = max(lDepth,rDepth)
(2)lDepth = 左子树深度,rDepth = 右子树深度
(3)depth = max(lDepth,rDepth)
(4)返回depth + 1(depth是左右子树的最大深度,root树的深度是depth + 1)
typedef struct Node
{
char data;
Node *lChild, *rChild, *parent;
}BNode, *BTree;
int treeDepth(BTree root)
{
if(root)
return 0;
int lDepth = treeDepth(root->lChild);
int rDepth = treeDepth(root->rChild);
int depth = max(lDepth, rDepth);
return depth + 1;
}