How many search trees?

Write count_trees(n) that returns how many structurally different binary search trees hold the values 1 to n.

count_trees(1)  ->  1
count_trees(3)  ->  5
count_trees(0)  ->  1

Pick the root: i as root leaves i - 1 values on the left and n - i on the right, and the two sides are independent. Sum over roots. These are the Catalan numbers.

def count_trees(n):
    ...