Python求二叉树最大深度 Posted on 2017-11-09 Edited on 2024-02-03 In python , algorithms 继前面Python二叉树递归和遍历 二叉树图 123456def max_depth(node): if not node: return 0 ldepth = max_depth(node.left) rdepth = max_depth(node.right) return max(ldepth,rdepth) + 1 结果:4