🚀 Phases 1–5 are live — Days 1–17 cover the foundations and the algorithmic patterns. See the roadmap →
Day 22 - Minimum Spanning TreesPractice QuestionsOverview

MST Practice Questions

Eight problems covering every algorithm and pattern in the chapter. The easy problems test pure union-find; the medium ones require recognizing the MST framing; the hard ones combine techniques.

Before reading any solution, ask:

  1. Is this a “connect all nodes at minimum cost” problem? → MST (Kruskal or Prim).
  2. Does it ask about connectivity or cycles? → Union-Find.
  3. Is the graph implicitly complete (all pairs connected)? → Prim’s dense O(V²) variant.
  4. Does it involve two types of edges or constraints? → Dual union-find or virtual node trick.

The pattern is almost always visible once you squint at the problem the right way.

Easy

ProblemPatternStatus
Min Cost to Connect All PointsPrim’s dense O(V²) on implicit complete graphAvailable
Redundant ConnectionUnion-Find — detect the first cycle-forming edgeAvailable

Medium

ProblemPatternStatus
Number of Operations to Make Network ConnectedUnion-Find — count components and spare cablesAvailable
Remove Max Number of Edges to Keep Graph Fully TraversableDual Union-Find (Alice + Bob)Available
Most Stones Removed with Same Row or ColumnUnion-Find on row/column indicesAvailable
Accounts MergeUnion-Find on email stringsAvailable

Hard

ProblemPatternStatus
Find Critical and Pseudo-Critical Edges in MSTKruskal with force/skip per edgeAvailable
Swim in Rising WaterBinary search + BFS, or min-max path (MST-adjacent)Available

More Practice (Coming Soon)

ProblemPatternStatus
Optimize Water Distribution in a VillageVirtual node + KruskalComing Soon
Minimum Spanning Tree (generic)Kruskal / PrimComing Soon
Connecting Cities With Minimum CostStandard KruskalComing Soon
Min Cost to Repair EdgesModified KruskalComing Soon
Minimum Cost to Connect Two GroupsDP on subsets + MSTComing Soon
Smallest String With SwapsUnion-Find on index pairsComing Soon
Satisfiability of Equality EquationsUnion-Find on variablesComing Soon
Largest Component Size by Common FactorUnion-Find with factor groupingComing Soon