二叉树,删除根

时间:2016-04-05 09:54:04

标签: c++ tree binary-tree

我想删除名字,它是二叉树中的根。

void remouve() // cpp file
patient person;
bool found = false;
tree.RetrieveItemRoot(person, found);
tree.DeleteItem(person);

\\\\\\\\\\\\\\ 模板//.h文件

void HeapType::Delete(HeapNode*& tree, patient item, bool& found)
{
    if (tree == NULL) {
        found = false;  // item is not found.
        return;
    }
    Delete(tree->left, item, found);
    if (found) return;
    Delete(tree->right, item, found);
    if (found) return;
    if (item.firstName == tree->info.firstName) {
        deleteNode(tree);
        found = true;
    }
}

模板

void HeapType::DeleteItem(patient item)
{
    bool found = false;
    Delete(root, item, found);
}

模板

void HeapType::modify(HeapNode*& tree, patient item)
{
    item.gravity = new item.gravity;
}

模板

void HeapType::modifyItem(patient item)
{
    Delete(root, item);
}

0 个答案:

没有答案