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
Recommended Posts:
- Introduction to Data Structures | 10 most commonly used Data Structures
- Data Structures | Binary Trees | Question 1
- Data Structures | Binary Trees | Question 15
- Data Structures | Binary Trees | Question 3
- Data Structures | Binary Trees | Question 15
- Data Structures | Binary Trees | Question 6
- Data Structures | Binary Search Trees | Question 1
- Data Structures | Binary Search Trees | Question 2
- Data Structures | Balanced Binary Search Trees | Question 2
- Data Structures | Binary Search Trees | Question 3
- Data Structures | Binary Search Trees | Question 4
- Data Structures | Binary Search Trees | Question 5
- Data Structures | Balanced Binary Search Trees | Question 2
- Data Structures | Binary Trees | Question 8
- Data Structures | Binary Trees | Question 9
- Data Structures | Binary Trees | Question 11
- Data Structures | Binary Search Trees | Question 6
- Data Structures | Binary Trees | Question 12
- Data Structures | Binary Trees | Question 13
- Data Structures | Binary Search Trees | Question 7

