Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working insert / delete case #1

Open
ALEXks opened this issue Jul 12, 2019 · 5 comments
Open

Not working insert / delete case #1

ALEXks opened this issue Jul 12, 2019 · 5 comments

Comments

@ALEXks
Copy link

ALEXks commented Jul 12, 2019

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;
}
@anandarao
Copy link
Owner

anandarao commented Jul 12, 2019 via email

@ALEXks
Copy link
Author

ALEXks commented Jul 12, 2019

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.

@anandarao
Copy link
Owner

Can you send a pull request if you have a fix ? :) I've lost touch of this repo.

@ALEXks
Copy link
Author

ALEXks commented Jul 15, 2019

Sorry, I do not want to look for an error =)

@JohnnyP0T
Copy link

I am fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants