在树的每个级别上创建多个节点 [英] Creating multiple nodes at every level of a tree

查看:76
本文介绍了在树的每个级别上创建多个节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在寻找创建一棵树,以便从每个节点我将有10个子节点.我将升至6级.

我目前无法确定如何通过递归自动执行此操作?我想递归地开发这棵树.传播设施也应该在末尾. . .

请对此进行指导...

Hi,
I am looking to create a tree such that from every node i will have 10 child nodes. I will go up to 6 levels.

I am currently stuck to determine how to do this thing autmatically via recursion? I want to develop this tree recursively. Propogation facility should also be there at the end . . .

Please guide me regarding this...

推荐答案

由于您未提供任何代码,因此很难提供帮助.你的树长什么样?
通过使用递归,您可以将级别作为参数传递给函数.一旦达到6,您将不做任何事情就退出该函数(在其他情况下,该函数会继续调用自身).
It''s a bit difficult to help since you didn''t provide any code. How does your tree look like ?
By using recursion, you could pass the level as argument to the function. Once it is 6, you exit the function without doing anything (in the other cases, the function continues to call itself).


我正在尝试为功能开发树.假设我在空间XY坐标中有1000个数据点.现在,我正在对该数据执行k均值聚类(3个聚类).结果,我得到了三个小组.现在,我创建了一个具有三个节点的树.这3个节点将包含属于各个节点的数据点.

现在,我转到第一个子节点.再次应用k均值聚类以创建另外3个子节点.然后,我转到第二个子节点,并再次创建3个子节点,依此类推.这是深度2.
因此,以这种方式,我必须生成一棵树.而且我必须升至10级.此外,同时子节点的数量可能会从3个变化到3个. 5或10等.

我希望这些信息能给我一个清晰的印象.通常我们将其称为单词模型包中用于场景识别的词汇树.
I am trying to develop tree for features. let's say I have 1000 data points in space XY coordinates. Now I am performing k-mean clustering (3 Clusters) on this data. As a result I get three groups. Now I create a tree with three nodes. These 3 nodes will contain data points which belong to the respective nodes.

Now I go to first child node. Again apply k-mean clustering to create further 3 child nodes. Then I go to second child node and again create 3 child nodes and so on. This is depth 2.
So in this way I have to generate a tree. And i have to go up to levels 10. Moreover at same time number of child nodes may vary from 3 e.g. 5 or 10 etc.

I hope this information will give a clear picture what i am trying to make. Normally we call it vocabulary tree used in Bag of Word Model for scene recognition.


这篇关于在树的每个级别上创建多个节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆