If the number of nodes in the Complete Binary Tree is 2n-1, the number of leaf nodes is ()
A) N-1 B) 2 x n C) 2n-1 d) 2N
Resolution:
Number of Subtrees owned by a node
Proof: because the degree of all nodes in a binary tree is not greater than 2, the total number of nodes (recorded as N) should be equal to zero-degree knots and 1-degree knots (recorded as N1) and the sum of 2-degree Knots:
N = no + N1 + N2 (Formula 1)
On the other hand, the level 1 node has a child, and the Level 2 node has two children, so the total number of child nodes in the binary tree is:
NL + 2n2
Only the root node in the tree is not the child of any node, so the total number of nodes in the binary tree can be expressed:
N = N1 + 2n2 + 1 (formula 2)
Obtained from Formula 1 and formula 2:
No = n2 + 1
Completely Binary Tree n1 = 0
Therefore, n = N0 + N0-1 + 1 = 2n0
Binary Tree: number of nodes = number of sides + 1
That is, N0 + N1 + n2 = N1 + 2 * N2 + 1 ==> N0 = n2 + 1
Number of Binary Tree nodes [N0, N1, N2]