Discrete Mathematics Graphs Trees 
(a) A tree $T = (V, E)$ has exactly one vertex each with degrees $2, 3,\ldots , 7$ and no vertices with degrees $> 7$. How many edges does $T$ have?
(b) Same question with $n$ instead of $7$, where $n\ge 2$.

This was a question and they used the handshaking lemma and $|E| = V-1$.
And I don’t know how they combined to get the result??
 A: Use that fact that in a finite undirected graph $G = (V,E)$ we have
$\sum_{v \in V} \text{deg}(v) = 2 |E|$
(The handshaking lemma is a consequence of this identity.) 
In both the general and the special case where $n=7$, you know the sum of the degrees.
A: Let $e$ be the number of edges of $T$. Suppose that $T$ has $\ell$ leaves (vertices of degree $1$). Then the sum of the degrees of the vertices of $T$ is
$$\ell+2+3+4+5+6+7=\ell+27\;,\tag{1}$$
so by the handshaking lemma 
$$e=\frac{\ell+27}2\;.\tag{2}$$
On the other hand, $T$ has $\ell+6$ vertices, so $e=\ell+5$. Therefore
$$\ell+5=\frac{\ell+27}2\;,\tag{3}$$
so $2\ell+10=\ell+27$, $\ell=17$, and $e=17+5=22$.
If you replace $7$ by $n$, $(1)$ becomes
$$\ell+2+3+\ldots+n=\ell+\frac{n(n+1)}2-1\;,$$
and $(2)$ becomes
$$e=\frac12\left(\ell+\frac{n(n+1)}2-1\right)\;.$$
$T$ then has $\ell+n-1$ vertices, so it has $\ell+n-2$ edges, and $(3)$ becomes
$$\ell+n-2=\frac12\left(\ell+\frac{n(n+1)}2-1\right)\;.$$
To finish the problem, solve this for $\ell$ in terms of $n$, and then use the fact that $e=\ell+n-2$ to get $e$ in terms of $n$.
