离散数学之图论之树

树的知识点相对图而言更集中一些,搞定这几个方面就行了。
满m-叉树内点数,叶子数,节点总数之间的关系;
树的三种遍历;

注意树是定义在无向图上的。
Theorem: An undirected graph is a tree if and only if there is a unique simple path between any two of its vertices.
这里的level/height是从0开始定义的,和DSAA中应该是相同的。

树的基本定理参见DSAA中的树吧。
注意此处的ancestor不考虑自己。

m-ary tree

注意 m叉树full/complete的区别。
The tree is called a full m-ary tree if every internal vertex has exactly m children.
要么没孩子,要么就有m个孩子。

这是从链接处找到的例子。

Theorem: A full m-ary tree with i internal vertices has \(n = mi + 1\)

vertices.
要掌握已知m和n/i/l中的其中一个求其他两个的方法。
Using \(n = mi + 1\) and \(n = i + l\)

If an m-ary tree of height h has l leaves, then \(h \leq \lceil log_m l\rceil\). If the m-ary tree is full and balanced, then \(h = \lceil log_m l\rceil\).

后半句的证明只需要证不能取\(h = \lceil log_m l\rceil - 1\)就可以了

2-ary tree

Definition: An ordered rooted tree is a rooted tree where the children of each internal vertex are ordered. Ordered rooted trees are drawn so that
the children of each internal vertex are shown in order from left to right.

有了order,就有了二叉树的左右子树。

Tree Traversal

Preorder Traversal

先访问根。

Inorder Traversal

中间访问根。

Postorder Traversal

最后访问根。

Expression Trees

posted @ 2022-05-29 21:35  爱吃番茄的玛丽亚  阅读(225)  评论(0)    收藏  举报