The concept and nature of trees and forests

All data structures, algorithms and applications curricular templates please click: https://blog.csdn.net/weixin_44077863/article/details/101691360

First, the concept and definition of trees and forests

1, the characteristics of the tree: the tree node (except the root node) and has a plurality of direct successor direct precursor, the tree is a tree (linear) structure.

2, the tree of nodes: nodes of the tree to its out-degree, i.e. the number of son

3, the parent node, the node son, sibling, ancestor node, descendant node, leaf nodes (also known as a terminal node, the external node is 0),

       The branch node (also known as non-leaf nodes, internal nodes, not 0 degree)

4, of the trees: the maximum value of the node

5, height and depth: Science Press Xian super data structure prescribed depth from 0, 1 height from the beginning, nothing written this provision, written in question will see specific provisions

6, the depth of the junction (junction layers): an increase from top to bottom

7, the height of the node: Science Press Xian super data structure did not make this concept because there are two definitions of the concept of statement

                              ① the node height to the lowest node

                              ② The node of the subtree root node height

8, the tree height: sequentially increases from bottom to top

9, ordered tree: all subtrees between each node determines the presence of an order relationship (i.e., the son sequential)

10, unordered tree: determining the relationship between the order (i.e., no son order) is not present between each of all the sub-tree node

11, a binary tree: ordered tree of the tree is 2 (note ordered tree, l and r can not be reversed)

12, the forest: m> = 0 configuration tree forest

13, understanding and expand: there is a tree on the nature of the map, point the relationship is determined by the selected root node. Usually we just put an arrow pointing to the tree omitted.

                                For an n-node undirected graph, construct a tree of n random manner

Second, the tree representation (to find out)

1, a tree representation (common)

2, Venn diagram representation

3, recessed representation

4, the nested bracket notation

Third, the nature of the tree

1, the tree node in the tree = degrees of all the nodes and the 1 + (sum of all the nodes and equal to the number of descendants of the root node)

2, the tree of degree m, the i-th layer at most m^i nodes (i> = 0)

3, the height is h, a degree at most m tree  (m^h-1)/(m-1)nodes (geometric series Solution)

4, n nodes, the tree of degree m, the minimum height of \log_{m}(n(m-1)+1)rounding up

Fourth, several special binary tree

1, complete binary tree: In addition to the above the last layer of the other layers are full, and the last layer of the leftmost node discrete locations

                  Features: the last leaf node in a certain layer or the penultimate

2, full binary tree: each layer is full, full binary tree is the most special of complete binary tree

              Features: Only 0 degree or 2 degrees of the nodes, there is no degree of node 1, node number n = 2 ^ h - 1, leaf nodes at the final layer must

3, the expansion of a binary tree: Add enough empty leaf on the number two son nodes

                  Features: The new point must be the leaf node, the node must be the old branch node

          Exclusive concept: the external path length E: root path length of each space and leaves

                              Internal path length I: root node to each internal node in the path length and

Fifth, the nature of the binary tree (remember all recommended)

Set to 0 degree as the number of nodes for n1,2 n0,1 is n2, the number of nodes n, the height h (h> = 1)

1、n = n0 + n1 + n2

2, n = n1 + 2 * n2 + 1

3, n0 = n2 + 1

4、2^h^-^1-1<n<=2^h-1

5, the minimum height of  \log(n+1) rounding up

6, the i-th layer (i> = 0) at most  2^i nodes

7, the height h = complete binary tree  \log(n+1) is rounded up

8, a full binary tree leaf nodes of nodes branching points = 1 +

Sixth, storage

1, the chain storage or sequential storage

2, sequentially stores the subject characteristic Sons

      ① numbered starting from 1, 2i left his son, 2i + 1 is the right son, i / 2 for his father

      ② numbered from 0, 2i + 1 is the left son, 2i + 2 is the right son, (i - 1) / 2 as the father  

Seven small problem:

1, the tree node is not a leaf node is a branch node, right?       

   answer

2, the root of the tree branch nodes must be, right?

   Answer: False. Only root, root for the leaf nodes.

Eight, reasoning and proof:

1, the height is h, m degree of a tree, on the number of nodes n have,(m^h^-^1-1)/(m-1)< n <=(m^h-1)/(m-1)

2, proved to be three or 4:

       Conclusion VI 1 available

       \log_{m}(n(m-1)+1)<=h< \log_{m}(n(m-1)+1)+1 So is proved

 

Published 49 original articles · won praise 0 · Views 1715

Guess you like

Origin blog.csdn.net/weixin_44077863/article/details/103100613