14059. [GESP202609 六级 C++] 第 10 题

[GESP202609 六级 C++] 第 10 题

下面函数在二叉搜索树中查找值 x。横线处应填写(  )。

TreeNode *searchBST(TreeNode *root, int x) {
    if (root == nullptr || root->val == x)
        return root;
    if (x < root->val)
        return searchBST(root->left, x);
    return __________________________;
}

{{ select(1) }}

  • searchBST(root->left, x)

  • searchBST(root->right, x)

  • searchBST(root, x + 1)

  • root->right