二叉树深度
dp思想求解,若当前结点非空,则该树的深度为1加左右子树更大的那一支深度,否则返回0。
treeDepth={1+max(leftDepth,rightDepth),Tree≠NULL0,else
t
r
e
e
D
e
p
t
h
=
{
1
+
m
a
x
(
l
e
f
t
D
e
p
t
h
,
r
i
g
h
t
D
e
p
t
h
)
,
T
r
e
e
≠
N
U
L
L
0
,
e
l
s
e
附code: