ACM 关于 树和子数的概念

问题描述:

ACM 关于 树和子数的概念
B.Tree
Dear contestant,I bet you must know what a tree represent.In data structure,we learn
a tree is a graph in which every two nodes have and only have one path.
Here comes an easy problem,given a tree with nodes have its weight,the weight of a
tree is the sum of the weight of all nodes on it.Now we have a chance to divide the
tree into two subtrees,and we want to know the minimum difference between the two
subtrees‟weight.
Input
The first line contains a single integer T,indicating the number of test cases.
Each test case begins with one integer N (2
1个回答 分类:英语 2014-11-12

问题解答:

我来补答
树是图论里的概念,在数据结构或离散数学的书籍上都有介绍,LZ所说的树是树的特例(2叉树或n叉树).
树的定义:设G=(P,L)是图,如果G是连通的,并且无回路,则称G为树.
无回路的图(可能不连通)也称为森林.
eage of tree 是指树的一条边.
 
 
展开全文阅读
剩余:2000