First, the concept
Unlike the "degrees" in graph theory, the degree of the tree is defined as: the number of children in the root tree T, node X is called the degree of X. That is: in the tree, the node has a few bifurcation, the degree is a few.
A useful little formula: node in the tree = Total Fork number +1. (The number of forks here is the sum of the degrees of all nodes).
Second, the degree of calculation
1. The degree of the tree T is 4, where the number of nodes with 1,2,3,4 is 4,2,1,1, then the number of leaves in T is?
Solution:
The number of leaves is 0, then the number of leaves is X, then the total score of the tree is 1*4+2*2+3*1+4*1=15; the number of nodes in this tree is 16 (a formula is involved here; the number of nodes = the number of forks is +1, which can be observed by the graph). And according to the topic can know the number of vertices can also list a formula: 4+2+1+1+x can get the equation: 4+2+1+1+x=16;x=8 is the number of leaves.
Because this is a problem in the data structure: In general, there is a direction to the tree, so the degree of the leaf node is 0, to distinguish it from the discrete mathematics of the non-tree leaf node degree of one. In the data structure commonly used in the formula is: Two tree: The number of nodes with degrees 0 = 2 nodes +1 (n0=n2+1) This formula can be deduced from the above calculation idea (generally in the binary tree there are more formulas, as long as you clearly define the tree, draw a diagram, you can find out the pattern according to the graph)
The relationship between the degree of the tree and the node count