Algorithms and Data Structures · Senior · Question 47 of 75

Why can't union-find detect cycles in a directed graph?

Explanation

Union-find tracks connectivity, not direction. In a DAG two paths to the same vertex (a diamond) would join already connected vertices, which looks like a cycle but isn't one.

Further reading

Problem with a question

Algorithms and Data Structures · Senior · question 47

Test yourself

Take the Algorithms and Data Structures · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz