当前位置:网站首页>The nature and proof of the center of gravity of [mathematics] tree
The nature and proof of the center of gravity of [mathematics] tree
2022-07-26 23:19:00 【Record algorithm solution】
Definition :
There are many equivalent definitions of the center of gravity of a tree , We use this definition : The center of gravity of the tree refers to , This point is the point that minimizes the number of nodes of the largest subtree . Let the number of nodes of the tree be n n n.
nature 1:
spot u u u Is the center of gravity of the tree , If and only if the number of nodes of its largest subtree is less than or equal to ⌊ n / 2 ⌋ \lfloor n/2\rfloor ⌊n/2⌋.
prove :
Proband ⇒ \Rightarrow ⇒. If u u u Center of gravity , But the number of nodes of its largest subtree is greater than ⌊ n / 2 ⌋ \lfloor n/2\rfloor ⌊n/2⌋, Then consider the root of the subtree v v v. set up s [ x ] s[x] s[x] by x x x Size of subtree , that s [ v ] > ⌊ n / 2 ⌋ , n − s [ v ] < ⌊ n / 2 ⌋ < s [ v ] s[v]>\lfloor n/2\rfloor,n-s[v]<\lfloor n/2\rfloor<s[v] s[v]>⌊n/2⌋,n−s[v]<⌊n/2⌋<s[v], So as to v v v For the root of a tree , The size of its largest subtree must be less than s [ v ] s[v] s[v] Of , And u u u For the center of gravity contradiction .
Re evidence ⇐ \Leftarrow ⇐. If u u u The number of nodes of the largest subtree of is less than or equal to ⌊ n / 2 ⌋ \lfloor n/2\rfloor ⌊n/2⌋, but u u u Not the center of gravity , hypothesis v ≠ u v\ne u v=u but v v v Center of gravity , consider v v v Including u u u That little tree of mine , from u u u From the perspective of , The number of nodes of its largest subtree is less than or equal to ⌊ n / 2 ⌋ \lfloor n/2\rfloor ⌊n/2⌋, So get rid of u u u To v v v That path u u u The sum of nodes of the remaining subtrees is greater than or equal to n − 1 − ⌊ n / 2 ⌋ n-1-\lfloor n/2\rfloor n−1−⌊n/2⌋, thus v v v Including u u u The size of the subtree of is greater than or equal to n − ⌊ n / 2 ⌋ n-\lfloor n/2\rfloor n−⌊n/2⌋. If n n n It's odd , be n − ⌊ n / 2 ⌋ > ⌊ n / 2 ⌋ n-\lfloor n/2\rfloor>\lfloor n/2\rfloor n−⌊n/2⌋>⌊n/2⌋, And v v v It's the contradiction of focus . If n n n It's even , Only in u u u and v v v The number of nodes of the largest subtree of is equal to n / 2 n/2 n/2 also u u u And v v v There is no contradiction when connecting , At this time, these two points are the center of gravity . The above proof proves that there is no other center of gravity in this situation .
inference :
Only when the number of nodes is not unique can there be two barycenters , And the center of gravity is at most two . When the center of gravity has two , They are adjacent nodes . The number of nodes of the largest subtree of the barycenter is determined .
nature 2:
set up d [ u ] d[u] d[u] Is all points and u u u The sum of the distances ( Let's say that the edge weights are 1 1 1), So if and only if u u u When the center of gravity d [ u ] d[u] d[u] Minimum .
prove : Proband ⇐ \Leftarrow ⇐. hypothesis v v v bring d [ v ] d[v] d[v] Minimum , also v v v Not the center of gravity , that v v v One subtree is larger than ⌊ n / 2 ⌋ \lfloor n/2\rfloor ⌊n/2⌋ Of , If you will v v v Move a step towards the sub tree , be d [ v ] d[v] d[v] It's bound to get smaller , contradiction . So if d [ v ] d[v] d[v] Minimum , that v v v It must be the center of gravity .
Re evidence ⇒ \Rightarrow ⇒. If d [ u ] d[u] d[u] Not the smallest , There is another point v v v bring d [ v ] d[v] d[v] Minimum , Then by nature 1 1 1, v v v Center of gravity , but u u u It's also the center of gravity , If the center of gravity is unique , This is a contradiction . If the center of gravity is not unique , Infer from the above , n n n It's even , u u u And v v v The number of nodes of the largest subtree of adjacent and two points is equal to n / 2 n/2 n/2, that d [ u ] = d [ v ] d[u]=d[v] d[u]=d[v], Also contradictory . So if u u u Center of gravity , d [ u ] d[u] d[u] Must be the smallest .
边栏推荐
- 杭州银行面试题【杭州多测师】【杭州多测师_王sir】
- 面试官问:JS的this指向
- Too busy with scientific research to take care of your family? Chen Ting: life cannot have only one fulcrum
- P5469 [noi2019] robot (Lagrange interpolation, interval DP)
- Learn various details and thoughts of chatroom implementation in Muduo
- Signal debugging document developed by car
- 菜鸟网络面试【杭州多测师】【杭州多测师_王sir】
- Security team: Recently, there is an rce vulnerability in the COREMAIL email client of windows, which may lead to the disclosure of the private key of the wallet
- Kingbasees SQL language reference manual of Jincang database (3.1.1.3. currency type)
- Differences between PHP round and sprintf functions
猜你喜欢

Import of MySQL data

The interviewer asked: this point of JS

程序员成长第二十九篇:如何激励员工?

Vector execution engine framework gluten announced the official open source and appeared at spark technology summit

Too busy with scientific research to take care of your family? Chen Ting: life cannot have only one fulcrum

实战项目:Boost搜索引擎

【MySQL】CentOS 7.9安装、使用MySQL-5.7.39二进制版

Programmer growth chapter 29: how to motivate employees?

黑马瑞吉外卖之新增员工

每周招聘|PostgreSQL数据库研发工程师,年薪60+,名企高薪,挑战自我!
随机推荐
2019 biometric forum successfully ended: these ten highlights should not be missed!
Reinforcement learning weekly 55: lb-sgd, msp-drl & robust reinforcement learning against
面试:你印象最深的BUG,举个例子
ESMFold: AlphaFold2之后蛋白质结构预测的新突破
Science | University of Washington uses AI and structural prediction to design new proteins
HCIA-R&S自用笔记(19)VLAN配置及实验、VLAN间路由
黑马瑞吉外卖之新增员工
Customer case | student education relies on observation cloud to create a new ecosystem of observable Smart Education
[hcip] OSPF special area, summary, certification
云原生微服务第一章之服务器环境说明
How can enterprises mitigate the security risks of Internet of things and industrial Internet of things
kalibr标定realsenseD435i --多相机标定
[hcip] OSPF route calculation
How to recover the original data when the U disk is damaged, and how to recover the damaged data when the U disk is damaged
企业数据治理面临的六大挑战!
Will the approval in advance affect the formal approval?
Security team: Recently, there is an rce vulnerability in the COREMAIL email client of windows, which may lead to the disclosure of the private key of the wallet
Learn various details and thoughts of chatroom implementation in Muduo
Interview questions of Bank of Hangzhou [Hangzhou multi tester] [Hangzhou multi tester _ Wang Sir]
Practical project: boost search engine