Degree calculation: Let the degree of tree T be 4, and the number of nodes with degrees 1, 2, 3 and 4 are 4, 2, 1 and 1 respectively, then the number of leaves in T is?
Solution: the degree of leaves is 0; Then let the number of leaves be x, and the total number of branches of this tree is1* 4+2 * 2+3 *1+4 *1=15; The number of nodes in this tree is 16 (here involves a formula; Number of nodes = number of forks+1, as can be observed from the figure). According to the title, the number of vertices can also be listed as an equation: 4+2+ 1+ 1+x to get the equation: 4+2+1+0+x =16; X=8 is the number of leaves.
Because this problem is a problem in data structure: it is a directed tree in general, so the degree of leaf nodes is 0, which is different from the degree of undirected leaf nodes in discrete mathematics. The commonly used formula in data structure is: binary tree: number of nodes with degree 0 = number of nodes with degree 2+1(n0=n2+ 1). This formula can be derived from the above calculation ideas (there are many formulas in general binary trees, so as long as you clearly define and draw a graph in the tree, you can find out the law according to the graph).