void Delete(TreeNode* tree, ItemType item)
{
if (item.ComparedTo (tree->info)==LESS)
Delete(tree->left, item);
else if (item.ComparedTo( tree->info)==GREATER)
Delete(tree->right, item);
else
DeleteNode(tree); // Node found
}
void GetPredecessor(TreeNode* tree, ItemType& data)
// Sets data to the info member of the right-most node in tree.
{
while (tree->right != NULL)
tree = tree->right;
data = tree->info;
}
void DeleteNode(TreeNode* tree)
{
TreeNode* tempPtr;
tempPtr = tree;
if(tree->left == NULL&&tree->right==NULL)
delete tempPtr;
else if (tree->left == NULL)
{
tree = tree->right;
delete tempPtr;
}
else if (tree->right == NULL)
{
tree = tree->left;
delete tempPtr;
}
else
{
GetPredecessor(tree->left, item);
tree->info =item;
Delete(tree->left, item);
}
}
so when i was delete the leaf don't work
so what can i do
with my regardes