码迷,mamicode.com
首页 > 其他好文 > 详细

how many different bst given n nodes?

时间:2015-05-13 18:50:26      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:

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

...

how many different bst given n nodes?

标签:

原文地址:http://www.cnblogs.com/miaoz/p/4501012.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!