Skip to content

removeLimit issues #34

@DanceBot1234

Description

@DanceBot1234

Hi - I know this is an old project but thanks for keeping it available.

When using limits.c::removeLimit with two children I often get circular loops in the trees. I've tried aligning that section of code with the psuedo-code in the linked wiki article, but I'm not 100% sure it's similar and I think calling removeLimit again at the end of that section results in the loops (line 142 of limits.c).

Replacing that section (lines 111-142 in limits.c) with a more straightforward copy of the wiki psuedo-code might make it easier to verify:

        /*Limit has two children*/
        ptr_successor = getMinimumLimit(limit->rightChild);  //  Line 7 of the wiki code

        if(limit->rightChild != ptr_successor){   // Line 8
            replaceLimitInParent(ptr_successor, ptr_successor->rightChild);  //  Line 9
            ptr_successor->rightChild = limit->rightChild;  //  Line 10
            ptr_successor->rightChild->parent = ptr_successor;  //  Line 11
        }

        replaceLimitInParent(limit, ptr_successor);  //  Line 13
        ptr_successor->leftChild = limit->leftChild;  //  Line 14
        ptr_successor->leftChild->parent = ptr_successor;  //  Line 15

I haven't come across any circular loops after substituting this code, so maybe it will help others having similar problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions