zoukankan      html  css  js  c++  java
  • Minimum no. of iterations to pass information to all nodes in the tree

    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.

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

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

  • 相关阅读:
    (转) Android的Window类
    android 打开文件
    Android线程优先级
    Hierarchy viewer problems
    android:windowSoftInputMode
    (转) Android 安全机制
    Mobl试用之helloword
    写给自己对软件测试经历的总结
    Mobl试用二
    黑马程序员面向对象基础:属性和方法
  • 原文地址:https://www.cnblogs.com/linyx/p/4084329.html
Copyright © 2011-2022 走看看