 We define a leaf to be a vertex with degree 1. Suppose G is a tree with N vertices. You might be a discrete mathematician if the first question you ask is, How many? And in this case, how many leaves could it have? Since G is a tree with N vertices, it has N minus 1 edges. So the handshake theorem tells us that the sum of the degrees of all vertices will be... Since trees are connected, no vertex has degree 0. So if we want to say something about leaves, let's start up with the simplest idea. Suppose there are no leaves. If no vertex has degree 1, then all N vertices have degree 2 or more. So the degree sum would be at least 2N, which is impossible. So every tree has at least one leaf. In fact, we can prove, well actually you can prove, every tree has at least two leaves. The fact that every tree has vertices of degree 1 suggests a pruning algorithm. Suppose we eliminate the leaves of a tree. Now the removal won't disconnect the graph, and it won't create a cycle. So eliminating the degree 1 vertices from a tree produces a connected graph with no cycles. But that's another tree. And this suggests a way we can decide if a graph is a tree. Suppose we have a graph that is a tree. Then removing all degree 1 vertices will produce another tree. So the new graph will also have degree 1 vertices. Contra positively, if removing the degree 1 vertices from a graph G does not produce a graph with degree 1 vertices, then G was not a tree. So for example we might try to decide if this horrific graph is a tree. So we'll remove degree 1 vertices and their incident edge. So let's start by removing this one. Then these two, which are on the same edge. Then this one. Then this one. Again these two are on the same edge, so we'll remove them. And we end with a graph where there are no degree 1 vertices. Since we end with a graph with no degree 1 vertices, the original graph is not a tree. Or how about this graph? We'll remove degree 1 vertices and their incident edge. And if we continue to do so, we'll end with a tree. But that doesn't mean the original graph was a tree. So the thing to keep in mind is if we start with a tree, the removal of degree 1 vertices will produce another tree. But we actually need the converse. If the removal of a degree 1 vertices produces a tree, then we started with a tree. We need to prove this. Technically we don't need to prove this, but if you hope to base a billion dollar industry on it, it's probably worth finding a proof. So let's consider the algorithm could end in one of two ways. Either we get down to two vertices joined by one edge, or we get down to a single vertex with no edges. Let's work our way backwards. So suppose we end with two vertices and one edge. Since we got here by eliminating vertices of degree 1, then in the previous stage we would have eliminated some number of vertices and the same number of edges. So our graph would have had 2 plus n0 vertices and 1 plus n0 edges. So it would be connected with 1 less edge than vertices, and we know that the connected graph with 1 less edge than vertices is a tree. Now lather rins repeat. If the previous step had eliminated n1 vertices and n1 edges, the graph would have this many vertices and this many edges. And again, that's one viewer edge, so it would still be a tree. And going all the way back to the beginning, the original graph must have been a tree. What if we end with an isolated vertex? This graph has one vertex and zero edges. And adding back the degree 1 vertices would give us this many vertices and this many edges. So the original graph would have been a tree as well. And so if you start with a tree, you end with a tree, and if you end with a tree, you must have started with a tree.