以下函数实现了二叉排序树(BST)的( )操作。
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def op(root, x):
if not root:
return TreeNode(x)
if x < root.val:
root.left = op(root.left, x)
else:
root.right = op(root.right, x)
return root
正在加载题目数据…
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析