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

  • 相关阅读:
    log4js日志
    webservice随记
    easyui+nodejs+sqlserver增删改查实现
    jsp、servlet笔记
    mysql随笔
    ssh登录实现
    UML和模式应用1: 面向对象的分析与设计
    Linux mmc framework2:基本组件之mmc
    Linux MMC framework2:基本组件之core
    Linux mmc framework2:基本组件之queue
  • 原文地址:https://www.cnblogs.com/linyx/p/4084329.html
Copyright © 2011-2022 走看看