Red-Black-Tree
Red-Black-Tree copied to clipboard
Not working insert / delete case
In this case I get an error:
for (int z = 0; z < 30000; ++z)
{
printf(" Z = %d\n", z);
if (z == 699)
printf("");
data = rand() % 5000 + 220;
rbTree1.insertValue(data);
q.push(data);
rbTree1.preorder();
if (q.size() >= 15)
{
rbTree1.deleteValue(q.front());
q.pop();
}
}
if Z equal 699 deletion fails with segfoult in the flowing
int RBTree::getColor(Node*& node)
{
if (node == NULL)
return BLACK;
return node->color;
}
Did you by any chance find the root cause ? :)
On Fri, 12 Jul 2019 at 09:00, Alexander [email protected] wrote:
In this case I get an error:
for (int z = 0; z < 30000; ++z) { printf(" Z = %d\n", z); if (z == 699) printf(""); data = rand() % 5000 + 220; rbTree1.insertValue(data); q.push(data); rbTree1.preorder();
if (q.size() >= 15) { rbTree1.deleteValue(q.front()); q.pop(); } }
if Z equal 699 deletion fails with segfoult in the flowing
int RBTree::getColor(Node*& node) { if (node == NULL) return BLACK;
return node->color;
}
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/anandarao/Red-Black-Tree/issues/1?email_source=notifications&email_token=ACZWUSSASVNUZPWD6DXKPQTP7AT2TA5CNFSM4ICDGTO2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G6ZXQXQ, or mute the thread https://github.com/notifications/unsubscribe-auth/ACZWUSQQNZOUP2SL32J4KY3P7AT2TANCNFSM4ICDGTOQ .
-- Thanks and Regards. Ananda Rao H
Did you by any chance find the root cause ? :) … On Fri, 12 Jul 2019 at 09:00, Alexander @.**> wrote: In this case I get an error: for (int z = 0; z < 30000; ++z) { printf(" Z = %d\n", z); if (z == 699) printf(""); data = rand() % 5000 + 220; rbTree1.insertValue(data); q.push(data); rbTree1.preorder(); if (q.size() >= 15) { rbTree1.deleteValue(q.front()); q.pop(); } } if Z equal 699 deletion fails with segfoult in the flowing int RBTree::getColor(Node& node) { if (node == NULL) return BLACK; return node->color; } — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#1?email_source=notifications&email_token=ACZWUSSASVNUZPWD6DXKPQTP7AT2TA5CNFSM4ICDGTO2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G6ZXQXQ>, or mute the thread https://github.com/notifications/unsubscribe-auth/ACZWUSQQNZOUP2SL32J4KY3P7AT2TANCNFSM4ICDGTOQ . -- Thanks and Regards. Ananda Rao H
Yes, and I think the main reason is appearance of DOUBLE_BLACK color in the nodes. You can easily repeat this case in Windows system (my be in Linux too) because RAND function creates the same sequence.
Can you send a pull request if you have a fix ? :) I've lost touch of this repo.
Sorry, I do not want to look for an error =)
I am fixed it.