how many different bst given n nodes?

Reference: http://stackoverflow.com/questions/3042412/with-n-no-of-nodes-how-many-different-binary-and-binary-search-trees-possib 

Recursion:

t(0) = 1

t(1) = 1

t(2) = t(0)t(1) + t(1)t(0) = 2

t(3) = t(0)t(2) + t(1)t(1) + t(2)t(0) = 5

t(4) = t(0)t(3) + t(1)t(2) + t(2)t(1) + t(3)t(0) = 14

t(5) = t(0)t(4) + t(1)t(3) + t(2)t(2) + t(3)t(1) + t(4)t(0) = 42

...

posted @ 2015-05-13 17:09  zmiao  阅读(153)  评论(0编辑  收藏  举报