RB Tree | Inser & Delete bugs
Hi,
For those who already seen my last post probably understand this one (XD)
So I am trying to implement a red black tree in C++ and it seems to be buggy \=
main:
Code:
int main()
{
RedBlackTree* rbt = new RedBlackTree();
rbt->Insert(new RBNode(1, BLACK));
rbt->Insert(new RBNode(4, BLACK));
RBNode* x = new RBNode(5, BLACK);
rbt->Insert(x);
rbt->Insert(new RBNode(3, BLACK));
rbt->Insert(new RBNode(2, BLACK));
rbt->Insert(new RBNode(6, BLACK));
//rbt->Delete(x);
rbt->Print();
cout << endl << "Success.";
return 0;
}
Classes:
Gavra's Pastebin - Pastebin.com
After running main I gets:
1, 3, 2, 4, 5, 6,
which isn't right since the print is in-order.
if you will remove the comment next to the delete call you will get this:
6, 4, 5, 6,
well I think you get what's wrong here
Your help would be really appriciated
Thank you.