Rosalind第78题:Enumerating Unrooted Binary Trees

Problem

Figure 1. This unrooted binary tree may be represented in Newick format by (((a,b),c),(d,e)); another way of encoding it is ((a,b),(c,(d,e))).

图1 这个无根的二叉树可以用([[((a,b),c),(d,e))的Newick格式表示; 另一种编码方式是((a,b),(c,(d,e))))。

Recall the definition of Newick format from “Distances in Trees” as a way of encoding trees. See Figure 1 for an example of Newick format applied to an unrooted binary tree whose five leaves are labeled (note that the same tree can have multiple Newick representations).

Given: A collection of species names representing  taxa.

Return: A list containing all unrooted binary trees whose leaves are these  taxa. Trees should be given in Newick format, with one tree on each line; the order of the trees is unimportant.

回顾“树中的距离Newick格式的定义,作为对进行编码的一种方式。有关 应用于无根二叉树的Newick格式的示例,请参见图1,该树的五标记为标记(请注意,同一棵树可以具有多个Newick表示形式)。

给定:代表以下物种名称的集合 分类单元。

返回值:包含所有无根二叉树的列表,这些树的叶子是这些分类单元。树木应以Newick格式给出,每行一棵树;树木的顺序并不重要。

Sample Dataset

dog cat mouse elephant

Sample Output

(((mouse,cat),elephant))dog;
(((elephant,mouse),cat))dog;
(((elephant,cat),mouse))dog;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值