Skip to content

extra path compression #48

Open
Open
@kananmammadli

Description

unionFind class method find has extra step. It does compression even if it is not needed.

while (p != root) { int next = id[p]; id[p] = root; p = next; }
can be modified to the following to bypass unnecessary step

while (id[p] != root) { int next = id[p]; id[p] = root; p = next; }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions