Skip to main content

Union-Find

Learn Union-Find (Graphs, Advanced DSA) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Redundant Connection - Finding the Edge That Creates a Cycle Given a graph that was originally a tree (n vertices, n-1 edges) with ONE extra edge added, find that extra edge. Process edges in order, union-ing their endpoints - the FIRST edge whose endpoints are ALREADY in the same set is the redundant one (adding it would create a cycle).

More lessons in Graphs