Should I use DFS, or something more advanced like union-find?

In problems such as finding connected components, is it better to use the more advanced algorithm such as union-find? I realize DFS could work for a lot of cases. Aiming for FANNG.

Comments (2)