‹ 上一题 下一题 ›

g6-05209. GESP-6级-2026-06-单选-第13题 未做

下面代码实现二叉搜索树的插入操作。假设树中不存在重复值,横线处应填写( )。

TreeNode* insertNode(TreeNode* root, int x) {
    if (root == nullptr) {
        return new TreeNode(x);
    }

    if (x < root->val) {
        __________________________
    } else {
        root->right = insertNode(root->right, x);
    }

    return root;
}
  • A. root->left = insertNode(root->left, x);
  • B. root = insertNode(root->left, x);
  • C. root->right = insertNode(root->left, x);
  • D. insertNode(root->left, x);
未选择
输入
输出

            
答案