Determine the count of Leaf nodes in an N | CPP program to find number of leaf nodes ; Function to calculate leaf nodes in n - ary tree ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int calcNodes ( int N , int I ) { int result = 0 ; result = I * ( N - 1 ) + 1 ; return result ; } int main ( ) { int N = 5 , I = 2 ; cout << " Leaf ▁ nodes ▁ = ▁ " << calcNodes ( N , I ) ; return 0 ; }