I was just dealing with AVL trees, insert, delete and other methods, so right now I am having a problem with my left rotation, when the node is not the root ( aka the node's parent is not equal to zero). So, a part of my method, actually the right beginning of it goes like this:
void LR (Node* &c)
{
if (c->_parent != 0)
{
if ( c == c->_parent->_left)
{
c->_parent->_left = c->_right;
}
else
c->_parent->_right = c->_right;
c->_right->_parent = c->_parent;
}
etc. etc.
So, when I have a node c, that has key 389, parent non zero and right child non zero too, with a key equal to 390, my code dumps and it says that right after this instr.:
c->_parent->_left = c->_right;
my right child, c->_right becomes null :/ I don't get it. Anybody?