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

Minimum no. of iterations to pass information to all nodes in the tree的更多相关文章

  1. [Swift]LeetCode783. 二叉搜索树结点最小距离 | Minimum Distance Between BST Nodes

    Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the ...

  2. [LeetCode] Minimum Distance Between BST Nodes 二叉搜索树中结点的最小距离

    Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the ...

  3. [LeetCode&Python] Problem 783. Minimum Distance Between BST Nodes

    Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the ...

  4. 783. Minimum Distance Between BST Nodes

    Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the ...

  5. leetcode leetcode 783. Minimum Distance Between BST Nodes

    Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the ...

  6. leetcode 783. Minimum Distance Between BST Nodes 以及同样的题目 530. Minimum Absolute Difference in BST

    Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the ...

  7. 【LeetCode】783. Minimum Distance Between BST Nodes 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 中序遍历 日期 题目地址:https://leetc ...

  8. leetcode 学习心得 (4)

    645. Set Mismatch The set S originally contains numbers from 1 to n. But unfortunately, due to the d ...

  9. 99 Lisp Problems 二叉树(P54~P69)

    P54A (*) Check whether a given term represents a binary tree Write a predicate istree which returns ...

随机推荐

  1. Angular JS 学习之过滤器

    1.过滤器可以使用一个管道字符(|)添加到表达式和指令中: 2.AngularJS过滤器可用于转换数据: **currency:格式化数字为货币格式: **filter:从数组项中选择一个子集: ** ...

  2. BZOJ 2565 回文串-Manacher

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2565 题意:中文题 思路:定义L[i],R[i].表示以i为左端点/右端点时,最长回文串长 ...

  3. dubbox编译

    dubbox编译要在命令行 切记切记 设置JAVA_HOME 设置maven路径 命令编译dubbox 设置M2_HOME环境变量 设置idea M2_HOME dubbox 服务端 http://w ...

  4. BZOJ 2002 [Hnoi2010]Bounce 弹飞绵羊 ——Link-Cut Tree

    [题目分析] 以前用分块的方法做过这道题目,现在再用LCT水一边,发现思路确实巧妙. 每次弹射,可以看作在一条边上走了过去,而且很重要的性质,每一个点的出边只有一条. 那么就很容易知道,可以用LCT维 ...

  5. 如何让Ue4画面产生振动效果

    可以使用CameraShake蓝图类,对应的C++类为UCameraShake. 这个类是通过修改PlayerController来达到效果

  6. ural 1249. Ancient Necropolis

    1249. Ancient Necropolis Time limit: 5.0 secondMemory limit: 4 MB Aerophotography data provide a bit ...

  7. ccc 模拟重力

    x=x+v v=v+gr cc.Class({ extends: cc.Component, properties: { velocity:{ default:null }, grivatity:{ ...

  8. sdoi 2009 & 状态压缩

    是不是平时在手机里玩吃豆豆游戏玩腻了呢?最近MOKIA手机上推出了一种新的围豆豆游戏,大家一起来试一试吧. 游戏的规则非常简单,在一个N×M的矩阵方格内分布着D颗豆子,每颗豆有不同的分值Vi.游戏者可 ...

  9. 桌面每日一句--桌面翻译工具(有道翻译,微软翻译,Google翻译)

    现在的翻译软件功能越来越多,也越来越臃肿,还不时弹广告,真的很烦恼. 鉴于这种情况,自己做了个翻译软件,能满足日常需求就好了.需要用的时候可以直接在桌面输入单词翻译,或者直接使用快捷键呼出翻译窗口.最 ...

  10. ACM: Long Live the Queen - 树上的DP

    Long Live the Queen Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u D ...