Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  A binary tree T has 20 leaves. The number of ... Start Learning for Free
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
Correct answer is option 'B'. Can you explain this answer?
Verified Answer
A binary tree T has 20 leaves. The number of nodes in T having two chi...
 
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.
View all questions of this test
Most Upvoted Answer
A binary tree T has 20 leaves. The number of nodes in T having two chi...
Explanation:


  • A binary tree is a tree data structure where each node has at most two children, which are referred to as the left child and the right child.


  • A leaf node is a node that does not have any children.


  • Let's assume that there are "x" nodes in the binary tree that have two children.


  • The total number of nodes in the binary tree would be (x + 20) because there are 20 leaf nodes.


  • In a binary tree, the total number of edges is one less than the total number of nodes. Therefore, the total number of edges in this binary tree would be (x + 20 - 1) = (x + 19).


  • If we consider each node in the binary tree (except for the leaf nodes), it would have either one child or two children. Therefore, the total number of edges in the binary tree would be twice the number of nodes that have two children and once the number of nodes that have one child.


  • We can write an equation based on the above observation as follows: (2x + y = x + 19), where "y" is the number of nodes that have one child.


  • Simplifying the above equation, we get x = 19 - y.


  • Since each non-leaf node in the binary tree has either one child or two children, the total number of non-leaf nodes in the binary tree would be (x + y).


  • Substituting the value of x from the above equation, we get the total number of non-leaf nodes as (19 - y + y) = 19.


Therefore, the correct answer is option B (19).
Free Test
Community Answer
A binary tree T has 20 leaves. The number of nodes in T having two chi...
If you keep 20 leaves and allot one parent to 2 leaves we get 10 parents (10 nodes with 2 children). Then if we allot one parent to each 2 of 10 nodes, We get 5 parents (5 nodes with 2 children).Then in that 5 nodes, 4 nodes (remember 1 node left here)will have 2 parents (2 nodes with 2 children )and for that 2 nodes 1 parent is assigned (1 node with 2 children) . For this one node and 1 node left before we assign one parent (1 node with 2 children) Total nodes with 2 children are. 10+5+2+1+1=19 nodes
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

A binary tree T has 20 leaves. The number of nodes in T having two children isa)18b)19c)17d)Any number between 10 and 20Correct answer is option 'B'. Can you explain this answer?
Question Description
A binary tree T has 20 leaves. The number of nodes in T having two children isa)18b)19c)17d)Any number between 10 and 20Correct answer is option 'B'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about A binary tree T has 20 leaves. The number of nodes in T having two children isa)18b)19c)17d)Any number between 10 and 20Correct answer is option 'B'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for A binary tree T has 20 leaves. The number of nodes in T having two children isa)18b)19c)17d)Any number between 10 and 20Correct answer is option 'B'. Can you explain this answer?.
Solutions for A binary tree T has 20 leaves. The number of nodes in T having two children isa)18b)19c)17d)Any number between 10 and 20Correct answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of A binary tree T has 20 leaves. The number of nodes in T having two children isa)18b)19c)17d)Any number between 10 and 20Correct answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of A binary tree T has 20 leaves. The number of nodes in T having two children isa)18b)19c)17d)Any number between 10 and 20Correct answer is option 'B'. Can you explain this answer?, a detailed solution for A binary tree T has 20 leaves. The number of nodes in T having two children isa)18b)19c)17d)Any number between 10 and 20Correct answer is option 'B'. Can you explain this answer? has been provided alongside types of A binary tree T has 20 leaves. The number of nodes in T having two children isa)18b)19c)17d)Any number between 10 and 20Correct answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice A binary tree T has 20 leaves. The number of nodes in T having two children isa)18b)19c)17d)Any number between 10 and 20Correct answer is option 'B'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev