Sunday, October 6, 2024
Google search engine
HomeData Modelling & AIData Structures | Binary Trees | Question 8

Data Structures | Binary Trees | Question 8

The number of leaf nodes in a rooted tree of n nodes, with each node having 0 or 3 children is:
(A) n/2
(B) (n-1)/3
(C) (n-1)/2
(D) (2n+1)/3

Answer: (D)
Explanation: Let L be the number of leaf nodes and I be the number of internal nodes, then following relation holds for above given tree (For details, please see question 3 of this post)

  L = (3-1)I + 1 = 2I + 1

Total number of nodes(n) is sum of leaf nodes and internal nodes

  n = L + I

After solving above two, we get L = (2n+1)/3
Quiz of this Question

Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!

RELATED ARTICLES

Most Popular

Recent Comments