二叉树T有20个叶子。 T中有两个孩子的节点数为
(A) 18
(B) 19
(C) 17
(D) 10到20之间的任何数字答案: (B)
解释:
所有度的总和= 2 * | E |。
在这里,将树视为k元树:
Sum of degrees of leaves + Sum of degrees for Internal Node except root + Root's degree = 2 * (No. of nodes - 1).
Putting values of above terms,
L + (I-1)*(k+1) + k = 2 * (L + I - 1)
L + k*I - k + I -1 + k = 2*L + 2I - 2
L + K*I + I - 1 = 2*L + 2*I - 2
K*I + 1 - I = L
(K-1)*I + 1 = L
Given k = 2, L=20
==> (2-1)*I + 1 = 20
==> I = 19
==> T has 19 internal nodes which are having two children.
有关证明,请参见握手引理和有趣的树属性。
该解决方案由Anil Saikrishna Devarasetty提供
这个问题的测验