πŸ–¨οΈ Printing Instructions: Press Ctrl/Cmd + P and select "Save as PDF".
1

Prim's, Kruskal's, and the Cut Property

2

Learning Goals

3

Problem Definition

4

Spanning Tree

5

Minimum Spanning Tree (MST)

6

Uniqueness

7

The Cut Property

8

Definition of a Cut

9

The Cut Property (Crucial)

10

Proof of Cut Property

11

Generic Greedy MST

12

Generic Algorithm

13

Two Instantiations

14

Kruskal's Algorithm

15

Strategy

16

Kruskal(G)

A = empty
for each vertex v:
    Make-Set(v)
Sort edges E by weight ascending
for each edge (u, v) in sorted E:
    if Find-Set(u) != Find-Set(v):
        A = A βˆͺ {(u, v)}
        Union(u, v)
return A
17

Disjoint Set Union (DSU / Union-Find)

18

Kruskal's Analysis

19

Kruskal Trace

20

Interactive: Kruskal's Algorithm

21

Prim's Algorithm

22

Strategy

23

Prim(G, r)

for each u in V:
    key[u] = ∞
    Ο€[u] = NIL
key[r] = 0
Q = V   // Min-priority queue keyed by key[]
while Q is not empty:
    u = Extract-Min(Q)
    for each v in Adj[u]:
        if v ∈ Q and w(u, v) < key[v]:
            Ο€[v] = u
            key[v] = w(u, v)   // Decrease-Key
24

Prim's Key Concepts

25

Prim's Analysis

26

Prim Trace

27

Interactive: Prim's Algorithm

28

Comparison

29

Kruskal vs Prim

30

Advanced Topics

31

Reverse-Delete Algorithm

32

BorΕ―vka's Algorithm

33

Practice Problems

34

Problem 1: Heaviest Edge

35

Problem 2: Lightest Edge

36

Problem 3: Squaring Weights

37

Problem 4: Adding a Constant

38

Common Pitfalls

39

Watch Out For...

40

Interactive Practice

41

Activity 1: Kruskal's Trace

42

Solution 1

43

Activity 2: Prim's Trace

44

Solution 2

45

Activity 3: Cut Property Application

46

Solution 3

47

Activity 4: Cycle Property

48

Solution 4

49

Activity 5: Prim vs. Dijkstra

50

Solution 5

51

Activity 6: Edge Count

52

Solution 6

53

Summary

54

Key Takeaways

55

Interactive: Kruskal's Algorithm

56

Supplementary Resources