Skip to content
Related Articles

Related Articles

Improve Article

GATE | GATE-CS-2015 (Set 2) | Question 20

  • Difficulty Level : Basic
  • Last Updated : 28 Jun, 2021

A binary tree T has 20 leaves. The number of nodes in T having two children is
(A) 18
(B) 19
(C) 17
(D) Any number between 10 and 20


Answer: (B)

Explanation:

Sum of all degrees = 2 * |E|.

Here considering tree as a k-ary tree :


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.

See Handshaking Lemma and Interesting Tree Properties for proof.



This solution is contributed by Anil Saikrishna Devarasetty

Quiz of this Question

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up
Recommended Articles
Page :