def balanced_tree(r, h, create_using=None):
 if (r == 1):
  n = (h + 1)
 else:
  n = ((1 - (r ** (h + 1))) // (1 - r))
 return full_rary_tree(r, n, create_using=create_using)

def balanced_tree ( r , h , create_using = None ) : if ( r == 1 ) : n = ( h + 1 ) else : n = ( ( 1 - ( r ** ( h + 1 ) ) ) // ( 1 - r ) ) return full_rary_tree ( r , n , create_using = create_using )
return the perfectly balanced r-ary tree of height h .