Union-Find Problem

The problem is to find if a given edge (a, b) is connected in a graph with vertices {a, b, c, …}. Naive Solution – O(n^2) Maintain a parent array of size (len of vertex array) Update an edge (a, b) with the index a & b in the vertex array ParentArray[a] = b ParentArray[b] […]

Read more