Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def count_binary_trees(N):
- binary_size = [0]*(N+1)
- binary_size[1] = 1
- def count_binary(N):
- if N < 0:
- return 0
- if binary_size[N]:
- return binary_size[N]
- left_size, right_size = 1, N-2
- counter = 0
- while right_size > 0:
- counter += count_binary(left_size)*count_binary(right_size)
- left_size += 1
- right_size -= 1
- binary_size[N] = counter
- return counter
- return count_binary(N)
- print(count_binary_trees(11))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement