题目
题目

CIS-279-OLH-CRN47413 Quiz: Chapter 7

单项选择题

Which XXX completes the leaf removal case in the C++ BinarySearchTree class's Remove() function? if (currentNode->left == nullptr && currentNode->right == nullptr) { if (parent == nullptr) { root = nullptr; } else if (parent->left == currentNode) { parent->left = nullptr; } else { parent->right = nullptr; } XXX return true; }

查看解析

查看解析

标准答案
Please login to view
思路分析
Question restatement: In the given C++ BinarySearchTree Remove() function, for the leaf node case (when currentNode has no children), which code should fill the placeholder XXX? Option analysis: - The provided answer choice is: delete currentNode; This is appropriate because, when a node is a leaf, there are no children to preserve or reattach. After disconnecting currentNode from its parent (by setting the corresponding parent pointer to nullptr), we must free the memory occupied......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!