Skip to content
Related Articles
Open in App
Not now

Related Articles

Data Structures | Binary Trees | Question 10

Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 28 Jun, 2021
Improve Article
Save Article

A complete n-ary tree is a tree in which each node has n children or no children. Let I be the number of internal nodes and L be the number of leaves in a complete n-ary tree. If L = 41, and I = 10, what is the value of n?
(A) 6
(B) 3
(C) 4
(D) 5

Answer: (D)

Explanation: For an n-ary tree where each node has n children or no children, following relation holds

    L = (n-1)*I + 1

Where L is the number of leaf nodes and I is the number of internal nodes.

Let us find out the value of n for the given data.

  L = 41 , I = 10
  41 = 10*(n-1) + 1
  (n-1) = 4
  n = 5

Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!