题库首页 › GESP等级认证(C++) › 题目 25644

下面代码实现二叉搜索树的插入操作。假设树中不存在重复值,横线处应填写( )。 TreeNode* insertNode(TreeNode* root, int x) { if (root == nullptr) { return new TreeNode(x); } if (x val) { ----------------// 空缺处填写 root->left = insertNode(root->left, x); } 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);

正确答案:A

试卷来源:202606 CCF-GESP编程能力等级认证C++六级真题

本卷相关题目

在线做题 同科目题库