Rosalind第88题:Counting Rooted Binary Trees

Problem

As in the case of unrooted trees, say that we have a fixed collection of  taxa labeling the leaves of a rooted binary tree . You may like to verify that (by extension of “Counting Phylogenetic Ancestors”) such a tree will contain  internal nodes and  total edges. Any edge will still encode a split of taxa; however, the two splits corresponding to the edges incident to the root of  will be equal. We still consider two trees to be equivalent if they have the same splits (which requires that they must also share the same duplicated split to be equal).

Let  represent the total number of distinct rooted binary trees on  labeled taxa.

Given: A positive integer  ().

Return: The value of  modulo 1,000,000.

就像无根树木一样,假设我们有固定的  标记有根的二叉树的叶子分类单元。您可能想验证(通过扩展“系统进化祖先”的计数)这样的树是否包含 内部节点和 总。任何边缘将仍编码一个分裂类群; 但是,这两个裂口对应于入射到将相等。如果两棵树具有相同的拆分,我们仍然认为它们是等效的(这要求它们也必须共享相同的重复拆分才能相等)。

让 表示上的不同根二叉树的总数 标记的分类单元。

给定:正整数 ()。

返回值: 模1,000,000

Sample Dataset

4

Sample Output

15
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值