Recall: We know that sum of all degree of vertices in a simple graph G is twice its number of edge. Let E(G) be the edge set of G and V(G) be the vertex set of G. Then
∑v∈Gd(v)=2|E(G)|
Let T be a tree on n vertices. By the property of tree, we know that number of edge in T is n−1. It follows that
n1(T)×1+n2(T)×2+n3(T)×3+n4(T)×4=2|E(T)|=2(n−1)
Further note that
n1(T)+n2(T)+n3(T)+n4(T)=n
By considering n2(T)=n3(T)=n4(T)=k and simplifying the above two equation yields us
20+2k+3k+4k=2(n−1)⟹20+9k=2(20+3k−1)⟹k=6
Therefore, total number of vertices in the tree is
n1(T)+n2(T)+n3(T)+n4(T)=20+3k=38.