Finding the shortest path between a pair of vertices.

Two sub-problems:

  • find(p, q) checks for connectivity between two vertices
  • union(p, q) connects two vertices
AlgorithmfindunionLimitation
Quick-FindSlow when union is expensive, tree is flat
Quick-UnionSlow when trees too tall, union and find both expensive
Weighted Union
Weighted Union with Path CompressionAlmost linear performance per operation. Trees are effectively flat