A18740. 以下函数可以正确完成二叉搜索树的插入,并保持二叉搜索树性质。class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def insertNode(root, x): if not root: return TreeNode(x) if x < root.val: root.rig…
判断题
困难
知识点
题目描述
以下函数可以正确完成二叉搜索树的插入,并保持二叉搜索树性质。
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def insertNode(root, x):
if not root:
return TreeNode(x)
if x < root.val:
root.right = insertNode(root.right, x)
else:
root.left = insertNode(root.left, x)
return root选项(单选)
答案解析
详细答案解析为会员权益,按每日次数查看。
开通 / 升级会员
上一题
下一题