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

Incorrect return value of Kruskal #204

Closed
tequ1lAneio opened this issue Jul 31, 2022 · 1 comment
Closed

Incorrect return value of Kruskal #204

tequ1lAneio opened this issue Jul 31, 2022 · 1 comment

Comments

@tequ1lAneio
Copy link

tequ1lAneio commented Jul 31, 2022

Hi, @loiane

I found an unexpected result of Kruskal for getting MST.
see https://github.com/loiane/javascript-datastructures-algorithms/blob/main/examples/chapter12/07-Kruskal.js#L18

When running the code above, the return value is [2, 2, 4, 2, 2] instead of the expected result [2, 2, 2, 2, 2].
Could you take a look at it? Thanks!

@loiane
Copy link
Owner

loiane commented Oct 27, 2024

Prim and Kruskal can have different results. It all depends on the algorithm, both would be valid results.

@loiane loiane closed this as completed Oct 27, 2024
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

2 participants