bfs/dfs time complexity:
this is simpler to implement, but has risk to stack overflow on deep recursions.
time complexity:
- O(M x N) in terms of grid, where M rows N is column
- O(V + E) in terms of graph (adjacency list), where V vertice E edges.
union find time complexity:
union find algorithm runs in almost constant time per operation. TLDR: is more complex and use more memory, but if you have a lot of graphs updates, this will be more performatic.
time complexity:
- O(⍺(1)) in terms of path compression and find.
when we talk about union find technique we talk about constant time amortized algorithms to process graphs or grids.