in DS edited by
21,281 views
51 votes
51 votes

In a binary tree, the number of internal nodes of degree $1$ is $5$, and the number of internal nodes of degree $2$ is $10$. The number of leaf nodes in the binary tree is

  1. $10$
  2. $11$
  3. $12$
  4. $15$
in DS edited by
21.3k views

1 comment

Although @Kai and @Arjun ji has provided good answer with reference. But before looking at their answer just try considering tree as directed graph.

7
7

10 Answers

91 votes
91 votes
Best answer

A node in a binary tree has degree $0, 1$ or $2$. 

Ref: http://faculty.cs.niu.edu/~mcmahon/CS241/Notes/bintree.html

We are given no. of $1$ degree node $= 5$, no. of $2$ degree nodes $= 10$. 

Total no. of edges $= 1*5 + 2*10 = 25$ (In tree degree is for outgoing edges only, and hence each degree corresponds to an edge)

So, total no. of nodes $= 25 + 1 = 26$ (No. of nodes in a tree is $1$ more than no. of edges).

Now, no. of leaf  nodes (nodes with $0$ degree) $= 26 - 5 - 10 = 11$.

Correct Answer: $B$

edited by
by

4 Comments

 see this "A binary tree is a directed graph and hence degree refers to outgoing degree only. We can also consider it as an undirected graph and apply graph rules- but by default it is a directed graph. " by arjun sir

0
0
just drawing an arbitrary tree with "the number of internal nodes of degree 1 is 5, and the number of internal nodes of degree 2 is 10."- we can calculate it.
0
0
just the idea ...what will its graph look like?
0
0
56 votes
56 votes
In a binary Tree,

no of nodes of degree 2 = no of leaves - 1.

No of nodes of degree 1 do not affect no of leaves !

No of leafs = No of nodes of degree 2 + 1 = 10 + 1 = 11

4 Comments

@arjun Sir 

@gatecse

A binary tree is a directed graph and hence degree refers to outgoing degree only. We can also consider it as an undirected graph and apply graph rules- but by default it is a directed graph.

 

Why this definition is not using in this:   https://gateoverflow.in/118300/gate2017-1-20 

1
1

val because in GATE2006 question we are using the definition of a tree defined in DATA STRUCTURES but in GATE2017 we are using the definition of a tree as a graph defined in GRAPH THEORY

NOTE: notice the word 10 vertices.

0
0
it must be no. of leaves =number of nodes of degree 2 +1 .
0
0
6 votes
6 votes
In a directed graph indegree of a graph = outdegree

Outdegree = 1*5 + 2*10

Let number of leaves be x

Indegree = x*1 + 14 *1 (all nodes except root have indegree = 1)

Outdegree = indegree

x = 11
by
4 votes
4 votes
$L$ = $T+ 1$

$L$ = number of leaf node

$T$ =  number of nodes with 2 child

$L =10+1$

$L= 11$
Answer:

Related questions