minimum spanning tree
Last edited: December 12, 2025constituents
an undirected, conected, weighted graph
requirements
- a spanning tree is a tree that touches all of the vericies (i.e. a graph with no cycles)
- minimum spanning tree is a tree that connects all of the vertices with minimum edge cost
algorithm
| Prim | Kurskal | |
|---|---|---|
| Grows a … | tree | forest |
| Runtime 1 | \(O\qty(m \log n)\) with a red-black tree | \(O\qty(m \log n)\) with union-find |
| Runtime 2 | \(O\qty(m + \log\qty(n))\) for Fib heap | Or \(O\qty(m)\) with radix sort |
Kruskal’s Algorithm
“smallest edge that doesn’t make a cycle”
red-blak
Last edited: December 12, 2025SU-CS161 TA Review
Last edited: December 12, 2025TODO: create a table—algo, problem it solves, runtime, conditions. Prof lemmas?
Shortest-Path Algorithms
Dijikstra’s Algorithm
Intuition: subpaths of shortest paths are shortest paths. \(O\qty(n \log n + m)\)
Bellman-Ford Algorithm
Intuition: Dijkstra but k rounds across the whole graph
Floyd-Warshall Algorithm
All-pairs shortest path. Naive solution is \(O\qty(n)O\qty(nm) = O\qty(n^{2}m)\) by running bell
DP Problems
- fib
- shortest path
- longest common subsequence
- knapsack of all kinds
- independent set
Greedy
- activity selection
- scheduling
- DO THIS ON REVIEW: Huffman Coding is Greedy
- minimum spanning tree
SU-CS229 OCT272025
Last edited: December 12, 2025Algorithms Index
Last edited: December 12, 2025Lectures
Divide and Conquer
Sorting
- merge sort: SU-CS161 SEP252025
- recurrence solving: SU-CS161 SEP302025
- median: SU-CS161 OCT022025
- randomized algos + quicksort: SU-CS161 OCT072025
- linear time sorting: SU-CS161 OCT092025
Data Structures
- red-black trees: SU-CS161 OCT142025
- hashing: SU-CS161 OCT212025
Graphs
- DFS/BFS: SU-CS161 OCT232025
- Strongly connected components: SU-CS161 OCT282025
- Dijikstra: SU-CS161 OCT302025
DP
- bellman-ford and Floyd-Warshall: SU-CS161 NOV112025
- more DP LCS, knapsack, independent set: SU-CS161 NOV132025
Greedy Algorithms
- greedy algorithms: SU-CS161 NOV182025
- MSTs: SU-CS161 NOV202025
Closing
- Max Flows, Min Cuts, and Ford-Fulkerson: SU-CS161 DEC022025
