def count(n):
if n == 0 or n == 1:
return 1
else:
sum = 0
left = 0
right = 0
for x in range(1,n+1):
left = count(x-1)
right = count(n-x)
sum += left * right
return sum
I was reading this post and I wondered if no of different binary search trees from n nodes is
(2n)! / ((n+1)! * n!)
from this post.
Then
- what will be the time complexity ? O(n!) ?
- what will be the recurrence relation ?