以下函数实现了二叉排序树(BST)的( )操作。
TreeNode* op(TreeNode* root, int x) {
if (!root) return new TreeNode(x);
if (x < root->val) root->left = op(root->left, x);
else root->right = op(root->right, x);
return root;
}
- A. 查找
- B. 插入
- C. 删除
- D. 遍历
正确答案:B