Practice45 min

Practice: Ordering & Connectivity

Topological sort with cycle detection and union-find for components, trees, and redundant edges.

Kahn's algorithm twice — first as a yes/no cycle check, then producing the actual order — followed by three union-find drills where the answers fall out of two facts: successful unions reduce the component count by one, and a union that finds both sides already rooted together has just caught a cycle.

Solving all problems completes this lesson automatically.