Minimum Spanning Trees

Spanning trees connect all nodes with minimum edges. Learn Kruskal's and Prim's algorithms.

48 lessons
142 min

Lessons

1. Intro

(Why we need MSTs)

3m

2. What is a Spanning Tree?

(Definition and properties)

3m

3. Minimum Spanning Tree (MST)

(Minimum total edge weight)

3m

4. The Cut Property

Foundation for MST algos

3m

5. The Cycle Property

(Avoiding unnecessary edges)

3m

6. Kruskal's Algorithm - Idea

(Sort edges, add greedily)

3m

7. Kruskal with Union-Find

(Detecting cycles efficiently)

3m

8. Kruskal's Time Complexity

(Sorting dominates)

3m

9. Kruskal's Algorithm - Pseudocode

(Step-by-step implementation)

3m

10. Prim's Algorithm - Idea

(Grow tree from one node)

3m

11. Prim with Priority Queue

(Finding lightest edge fast)

3m

12. Prim's Time Complexity

(Heap operations dominate)

3m

13. Prim's Algorithm - Pseudocode

(Step-by-step implementation)

3m

14. Kruskal vs Prim - When to Use Each

(Choosing the right algorithm)

3m

15. MST in Disconnected Graphs

(Handling multiple components)

3m

16. Problem - Road Reparation

CSES 1675 - MST or impossible

3m1 problems

17. Problem - Read Statement

(CSES 1675)

3m1 problems

18. Core Idea - Check Connectivity

(MST needs connected graph)

3m

19. Core Idea - Kruskal is Perfect Here

(Sort edges, union components)

3m

20. Algorithm - Kruskal with Validation

(Count edges added)

3m

21. Road Reparation - Implementation

(Kruskal with edge count)

3m1 problems

22. Problem - Implement Solution

(CSES 1675)

3m1 problems

23. Walkthrough - Road Reparation

(Example execution)

3m

24. Lessons from Road Reparation

(When MST doesn't exist)

3m

25. Problem - Min Cost to Connect All Points

LeetCode 1584 - Complete gr...

3m1 problems

26. Problem - Read Statement

(LeetCode 1584)

3m1 problems

27. Core Idea - Complete Graph

(n² edges to consider)

3m

28. Core Idea - Manhattan Distance

(Computing edge weights)

3m

29. Algorithm - Prim on Implicit Graph

(Compute edges as needed)

3m

30. Min Cost Connect - Implementation

(Prim with lazy heap)

3m1 problems

31. Problem - Implement Solution

(LeetCode 1584)

3m1 problems

32. Walkthrough - Min Cost Connect

(Example execution)

3m

33. Lessons from Min Cost Connect

(Implicit vs explicit graphs)

3m

34. Problem - Building Roads

CSES 1666 - MSF for components

3m1 problems

35. Problem - Read Statement

(CSES 1666)

3m1 problems

36. Core Idea - Find Components

(DSU or DFS)

3m

37. Core Idea - Connect Component Representatives

(Chain them together)

3m

38. Algorithm - Component Chaining

(DSU then connect)

3m

39. Building Roads - Implementation

(DSU and component list)

3m1 problems

40. Problem - Implement Solution

(CSES 1666)

3m1 problems

41. Walkthrough - Building Roads

(Example execution)

3m

42. Lessons from Building Roads

(MST ideas without weights)

3m

43. MST Uniqueness

(When is MST unique?)

3m

44. Second-Best MST

(Almost minimum spanning tree)

3m

45. MSTs in Practice

(Real-world applications)

3m

46. Quiz: Unique MST with Unique Weights

Knowledge check

2m1 problems

47. Quiz: Kruskal vs Prim on Dense Graphs

Knowledge check

2m1 problems

48. Section Recap

(What you learned)

3m

Practice Problems

1.
3.
Road ReparationCSESmedium
4.
MST UnificationCodeforceshard
5.
Edges in MSTCodeforceshard
6.

Ready to start learning?

Access all 48 lessons with interactive content and progress tracking.