0
我想刪除整個二叉搜索樹(樹中的每個節點),你認爲哪個功能會更好?刪除二叉搜索樹
private:
struct Node {
string value;
Node* left;
Node* right;
};
Node* root;
public:
BST() {
root = NULL;
}
~BST() {
delete root->left;
delete root->right;
}
或:
...
void destroyTree (Node*& tree) {
while (tree != NULL) {
tree = tree->left;
delete tree;
}
while (tree != NULL) {
tree = tree->right;
delete tree;
}
delete tree;
}
請添加標記** 'C' **最大化的觀衆人數。 –
@ J.Piquard如果你可以識別你自己的語言,你可以自己加上標籤 – Bergi
@Bergi,實際上標籤**'C++'**是帶有部分'class BST'聲明的正確標籤。 –