下列关于求解二叉树深度的Python代码的说法中,不正确的是?

mw143645 单选题 共 个子题
def getDepth(root):
    if root is None:
        return 0
    left_depth = getDepth(root.left)
    right_depth = getDepth(root.right)
    if left_depth < right_depth:
        return right_depth + 1
    else:
        return left_depth + 1
A

该代码可用于求解二叉树的深度

B

代码中函数getDepth()的参数root表示根节点,非根节点不可以作为参数

C

代码中函数getDepth()采用了递归方法

D

代码中函数getDepth()可用于求解各种形式的二叉树深度,要求该二叉树节点至少有left和right属性

正在加载题目数据…
已答 /
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析
讨论
发布
登录后参与讨论 立即登录
发布讨论需先绑定并验证手机号 去绑定手机号
加载中…
我
我
回复 @
回复 @
发送
还没有人讨论,来发表第一条吧