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是按迭代数排序后的坐标)。

  • 相关阅读:
    各种开源许可 license 区别
    iOS 开发中的问题
    CoreText 使用教程
    UIFontFamily
    iTunes Connect TERMS OF SERVICE
    apple开发者账号申请
    十款免费移动应用测试框架推荐
    ios读取通讯录信息
    Search API 官方文档 可以用了查看自己的app
    Sprite Kit 入门教程
  • 原文地址:https://www.cnblogs.com/linyx/p/4084329.html
Copyright © 2011-2022 走看看