第11852题 单选题
Python实现二叉树递归深度计算的height函数中,横线处应填入的正确语句是?
class Node:
    def __init__(self, data):
        self.data = data
        self.left = None
        self.right = None
def max_depth(root_node):
    if root_node is None:
        return 0
    else:
        left_depth = max_depth(root_node.left)
        right_depth = max_depth(root_node.right)

二叉树深度计算还可以采用二叉树的广度优先搜索来实现。以下基于二叉树的广度优先搜索实现的深度计算函数中横线上应填写( )。

class Node:
    def __init__(self, data):
        self.data = data
        self.left = None
        self.right = None
def height(root):
    if root is None:
        return 0
    else:
        left_height = height(root.left)
        right_height = height(root.right)
        ______________
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析