第38851题 单选题
删除二叉排序树中的节点时,如果节点有两个孩子,则横线处应填入( ),其中findMax和findMin分 别为寻找树的最大值和最小值的函数。
struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;
    TreeNode(int x): val(x), left(nullptr), right(nullptr) {}
};

TreeNode* deleteNode(TreeNode* root, int key) {
    if (!root) return nullptr;
    if (key < root->val) {
        root->left = deleteNode(root->left, key);
    }
    else if (key > root->val) {
        root->right = deleteNode(root->right, key);
    }
    else {
        if (!root->left) return root->right;
        if (!root->right) return root->left;
        TreeNode* temp = ____________; // 在此处填写代码
        root->val = temp->val;
        root->right = deleteNode(root->right, temp->val);
    }
    return root;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
知识点:
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析