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

Minimum no. of iterations to pass information to all nodes in the tree

时间:2014-11-09 06:13:47      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:des   blog   http   io   ar   for   on   2014   log   

Given a very large n-ary tree. Where the root node has some information which it wants to pass to all of its children down to the leaves with the constraint that it can only pass the information to one of its children at a time (take it as one iteration).

Now in the next iteration the child node can transfer that information to only one of its children and at the same time instance the child’s parent i.e. root can pass the info to one of its remaining children. Continuing in this way we have to find the minimum no of iterations required to pass the information to all nodes in the tree.

Minimum no of iterations for tree below is 6. The root A first passes information to B. In next iteration, A passes information to E and B passes information to H and so on.

bubuko.com,布布扣

from: http://www.geeksforgeeks.org/minimum-iterations-pass-information-nodes-tree/

每次只能传播到一个子结点,要使迭代次数最小,那么迭代数要求比较大的点应该先传播。父结点的迭代数应该就是子结点的迭代数的最大值+i+1(这里i是按迭代数排序后的坐标)。

Minimum no. of iterations to pass information to all nodes in the tree

标签:des   blog   http   io   ar   for   on   2014   log   

原文地址:http://www.cnblogs.com/linyx/p/4084329.html

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