Minimum Spanning Trees

Minimum spanning trees in algorithms: the cut property, Kruskal's algorithm with union-find, Prim's algorithm with a heap, and why neither gives shortest paths.

  • 9 cards
  • 4 questions
  • About 29 min
  • Intermediate to Advanced
Share

A minimum spanning tree connects every vertex of an undirected weighted graph for the least total weight, and the topic teaches the rule that lets it be built greedily and the two algorithms that do. It opens on the cut property: the lightest edge across any split of the vertices is safe. Kruskal's algorithm follows, traced edge by edge with union-find deciding what to skip, then written in Python, Java and TypeScript. Prim's algorithm comes next, growing one tree from a start vertex, with its code using a heap or a scan. A comparison says when to use each, a gotcha shows why the tree is not a map of shortest routes, and an exercise lays fibre between seven village halls.

Contents

9 cardsnot started