how many different bst given n nodes?

Reference: http://*.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

...

上一篇:NAT技术与代理服务器


下一篇:高性能网络server--I/O复 select poll epoll_wait之间的差