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是按迭代数排序后的坐标)。
Minimum no. of iterations to pass information to all nodes in the tree的更多相关文章
- [Swift]LeetCode783. 二叉搜索树结点最小距离 | Minimum Distance Between BST Nodes
Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the ...
- [LeetCode] Minimum Distance Between BST Nodes 二叉搜索树中结点的最小距离
Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the ...
- [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 ...
- 783. Minimum Distance Between BST Nodes
Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the ...
- 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 ...
- 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 ...
- 【LeetCode】783. Minimum Distance Between BST Nodes 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 中序遍历 日期 题目地址:https://leetc ...
- leetcode 学习心得 (4)
645. Set Mismatch The set S originally contains numbers from 1 to n. But unfortunately, due to the d ...
- 99 Lisp Problems 二叉树(P54~P69)
P54A (*) Check whether a given term represents a binary tree Write a predicate istree which returns ...
随机推荐
- (转)ACM next_permutation函数
转自 stven_king的博客 这是一个求一个排序的下一个排列的函数,可以遍历全排列,要包含头文件<algorithm>下面是以前的笔记 (1) int 类型的next_permuta ...
- Tactical Multiple Defense System 二分图
This problem is about a war game between two countries. To protect a base, your country built a defe ...
- <meta>元素
HTML <meta> 元素 meta标签描述了一些基本的元数据. <meta> 标签提供了元数据.元数据也不显示在页面上,但会被浏览器解析. META元素通常用于指定网页的描 ...
- angular.bind() 函数
angular.bind bind 函数有三个参数, 参一:是一个对象 参二:是一个 function 参三:是用来给参二传参数的,可写可不写,看你心情 参数也可以在调用函数的时候传,也可以当做第三个 ...
- 关于__IPHONE_OS_VERSION_MAX_ALLOWED和__IPHONE_OS_VERSION_MIN_ALLOWED的用法
简单来说, 这些编译期常量, 对运行时的环境判断完全无效, 它告诉编译器用哪一段代码来进行编译, 那那段代码里, 你仍然可以写运行到目标机器里会崩溃的代码, 从stackoverflow里拷两段示例代 ...
- 疯狂java笔记(七) - Java集合之Map
Map是以键值对(key-value)的形式来存储数据的.而且Map不允许key的重复,通过Map存储key-value对时,只需要考虑key的存储就可以,key存储后value就会跟着key(完全可 ...
- UVa1515 Pool construction(最小割)
题目 Source https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- jqgrid动态显示/隐藏某一列
jQuery("#grid_id").setGridParam().showCol("colname").trigger("reloadGrid&qu ...
- Start_Learning_Python 03 条件、循环
if循环 Python条件语句是通过一条或多条语句的执行结果(True或者False)来决定执行的代码块. 条件语句和循环语句可以有 else 子句,它在穷尽列表(以for循环)或条件变为 false ...
- BZOJ 1831 & 就是一个DP....
题意: 比如说,4 2 1 3 3里面包含了5个逆序对:(4, 2), (4, 1), (4, 3), (4, 3), (2, 1). 可惜的是,由于年代久远,这些数字里有一部分已经模糊不清了,为了方 ...