A binary tree T has n leaf nodes, the number of nodes of degree 2 in T is:

This question was previously asked in
ESE Electronics 2012 Paper 2: Official Paper
View all UPSC IES Papers >
  1. log2n
  2. n - 1
  3. n
  4. 2n

Answer (Detailed Solution Below)

Option 2 : n - 1
Free
ST 1: UPSC ESE (IES) Civil - Building Materials
6.2 K Users
20 Questions 40 Marks 24 Mins

Detailed Solution

Download Solution PDF

In an "m-ary" tree. the number of total nodes (N) is given by

N=mi + 1  ----(1)

Where,

i: Number of internal nodes

Also, in a tree, N=i + L   ----(2)

Where,

L=number of leaf nodes

Here m=2

From equation (1) and equation (2);

N = 2i + 1

2i + 1 = i + L

L = i + 1

The number of leaves are 1 plus the number of internal nodes in binary tree.

Here, given L=n, substitute above and we will get,

i = L - 1

Latest UPSC IES Updates

Last updated on May 28, 2025

->  UPSC ESE admit card 2025 for the prelims exam has been released. 

-> The UPSC IES Prelims 2025 will be held on 8th June 2025.

-> The selection process includes a Prelims and a Mains Examination, followed by a Personality Test/Interview.

-> Candidates should attempt the UPSC IES mock tests to increase their efficiency. The UPSC IES previous year papers can be downloaded here.

More Tree Questions

Get Free Access Now
Hot Links: teen patti - 3patti cards game downloadable content teen patti plus teen patti master 51 bonus teen patti star teen patti apk