binary tree delete one node

I have made a binary tree code in class and i wanted to delete one element from the tree I have but when i try to, it deletes all the elements with the same info, any suggestions or changes i could do?


void BinaryTree::Delete(int el) {


return Deleteimp(root, el);



}
void BinaryTree::Deleteimp(BTNode *rootNode, int el) {
BinaryTree newTree;


if (rootNode == 0)
return;

if (el == rootNode->info) // any circle in the tree
{
if (rootNode == root) // check if its root
{
delete root;
}

else if (rootNode->parent->left == rootNode)
{
rootNode->parent->left = 0;
}

else if (rootNode->parent->right == rootNode)
{
rootNode->parent->right = 0;
}

delete rootNode;

}


else
{
Deleteimp(rootNode->left, el);
Deleteimp(rootNode->right, el);
}
Topic archived. No new replies allowed.