Skip to content

extra path compression #48

Open
Open
@kananmammadli

Description

@kananmammadli

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; }

Metadata

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