首页 > 其他 > 详细

how many different bst given n nodes?

时间:2015-05-13 18:50:04      阅读:154      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!