## Overview

**Minimum Spanning Trees.** Given an undirected graph, a spanning tree T is a subgraph of G, where T is connected, acyclic, includes all vertices. The minimum spanning tree is the spanning tree whose edge weights have the smallest sum. MSTs are similar to SPTs, but despite intuition suggesting it may be the case, for many graphs, the MST is not the SPT for any particular vertex. See https://docs.google.com/presentation/d/1eZ6sCoAY8d-PAfyyTRG*EQ-BBNqxmTyJ2vS10ZzsGYg/edit#slide=id.g772f8a8e2*0_191.

**Cut Property.** If you divide the vertices up into two sets S and T (arbitrarily), then a crossing edge is any edge which has one vertex in S and one in T. Neat fact (the cut property): The minimum crossing edge for ANY cut is part of the MST.

**Prim's Algorithm.** One approach for finding the MST is as follows: Starting from any arbitrary source, repeatedly add the shortest edge that connects some vertex in the tree to some vertex outside the tree. If the MST is unique, then the result is independent of the source (doesn't matter where we start). One student at office hours likened this to the game of http://www.wikihow.com/Play-Sharks-and-Minnows, where you catch exactly one minnow during each iteration of the algorithm. Each time, the sharks get whichever minnow is closest to a shark.

Yet another way of thinking about Prim's algorithm is that it is basically just Dijkstra's algorithm, but where we consider vertices in order of the distance from the entire tree, rather than from source. Or in pseudocode, we simply change relax so that it reads:

```
relax(e):
v = e.source
w = e.target
currentBestKnownWeight = distTo(w)
possiblyBetterWeight = e.weight // Only difference!
if possiblyBetterWeight > currentBestKnownWeight
Use e instead of whatever we were using before
```

Notice the difference is very subtle! Like Dijkstra's, the runtime is O(E log V). We can prove that Prim's works because of the cut property.

**Kruskal's Algorithm.** As an alternate algorithm and as a showcasing of various data structures in the course, we also considered Kruskal's algorithm for finding an MST. It performs the exact same task as Prim's, namely finding an MST, albeit in a different manner. In pseudocode, Kruskal's algorithm is simply:

```
Initialize the MST to be empty
Consider each edge e in INCREASING order of weight:
If adding e to the MST does not result in a cycle, add it to e
```

That's it! The runtime for Kruskal's, assuming that we already have all of our edges in a sorted list and use a weighted quick union with path compression to detect cycles, is O(E log*V), or (E log E) if we have use a PQ instead. See slides for more details. We can prove that Kruskal's works because of the cut property.*

*Completely unimportant technical note: We can actually make an even tighter bound than O(E log*V) if we use the inverse Ackermann bound for WQUPC.

### C level

- Problem 1 and 2 from Princeton's Coursera course.
- Problem 2 from Princeton's Spring 2008 final
- Would Kruskal or Prim's algorithm work on a directed graph?
- True or false: Adding a constant to every edge weight does not change the solution to the MST problem.

### B level

- Adapted from Algorithms 4.3.8. Prove the following, known as the cycle property: Given any cycle in an edgew eighted graph (all edge weights distinct), the edge of maximum weight in the cycle does not belong to the MST of the graph.
- Problem 3 from Princeton's Fall 2009 final (part d is pretty hard).
- Problem 4 from Princeton's Fall 2012 final.
- Adapted from Algorithms 4.3.12. Suppose that a graph has distinct edge weights. Does its shortest edge have to belong to the MST? Can its longest edge belong to the MST? Does a min-weight edge on every cycle have to belong to the MST? Prove your answer to each question or give a counterexample.
- Adapted from Algorithms 4.3.20. True or false: At any point during the execution of Kruskalâ€™s algorithm, each vertex is closer to some vertex in its subtree than to any vertex not in its subtree. Prove your answer.
- True or False: Given any two components that are generated as Kruskal's algorithm is running (but before it has completed), the smallest edge connecting those two components is part of the MST.
- Problem 11 from my Fall 2014 final.
- Problem 13 from my fall 2014 final.

### A level

- Problem 3 from Princeton's Coursera course.
- Problem 3 from Princeton's Spring 2008 final.
- Adapted from Textbook 4.3.26: An MST edge whose deletion from the graph would cause the MST weight to increase is called a critical edge. Show how to find all critical edges in a graph in time proportional to E log E . Note : This question assumes that edge weights are not necessarily distinct (otherwise all edges in the MST are critical).