Determine the count of Leaf nodes in an N | Function to calculate leaf nodes in n - ary tree ; Driver Code
def calcNodes ( N , I ) : NEW_LINE INDENT result = 0 NEW_LINE result = I * ( N - 1 ) + 1 NEW_LINE return result NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 5 NEW_LINE I = 2 NEW_LINE print ( " Leaf ▁ nodes ▁ = ▁ " , calcNodes ( N , I ) ) NEW_LINE DEDENT