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 ...
随机推荐
- Uva 11988 Broken Keyboard
因为要经常移动这些字符,所以采用的数据结构是链表. next[i]起到的作用大概就是类似链表里的next指针. 0.需要注意的是,判断cur == last ? 如果 是 则 last=i 1.另外一 ...
- jade学习02
模版继承 ; block,extends ;如果是原生html文件的话,后缀html //layout.jade doctype html html head meat(charset='utf-8' ...
- yii2.0 的数据的 查 删
数据的查询 /** * 查询正在使用的数据 model 层 */ public function selectdata(){ return $this->find()->a ...
- Codeforces Round #342 (Div. 2)
贪心 A - Guest From the Past 先买塑料和先买玻璃两者取最大值 #include <bits/stdc++.h> typedef long long ll; int ...
- HTML5拖放事件(Drag-and-Drop,DnD)
拖放 拖放是一种常见的特性,即抓取对象以后拖到另一个位置.在 HTML5 中,拖放是标准的一部分,任何元素都能够拖放. 拖放是在“拖放源(drag source)”和“拖放目标(drop target ...
- ural 1073. Square Country
1073. Square Country Time limit: 1.0 secondMemory limit: 64 MB There live square people in a square ...
- Codeforces Round #244 (Div. 2) A. Police Recruits
题目的意思就是找出未能及时处理的犯罪数, #include <iostream> using namespace std; int main(){ int n; cin >> ...
- Android -- ListView(SimpleAdapter) 自定义适配器
aaarticlea/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA ...
- window下 配置gitlab ssh非端口22端口
git config --global user.name "jack" git config --global user.email "jackluo@xxx.com& ...
- MAT(Memory Analyzer Tool)工具入门介绍
1.MAT是什么? MAT(Memory Analyzer Tool),一个基于Eclipse的内存分析工具,是一个快速.功能丰富的JAVA heap分析工具,它可以帮助我们查找内存泄漏和减少内存消耗 ...