All data structures, algorithms and applications curricular templates please click: https://blog.csdn.net/weixin_44077863/article/details/101691360
Trees and forests turn binary tree is actually very simple, we simply like to talk about
Compliance is very simple, that is the left child right sibling law
Transfer binary tree:
=>
Forest transfer binary tree:
=>
=>
The next step is reduced to binary trees, the forest, but the truth is the same, very simple, we do not speak up
Is the right son back to brothers
Here the students to think of a question frequently asked, if only the right tree for his son this time it will not convert a BUG yet
So, the question to ask out really strange, first son no more tree around
Although inter-son does have order, but did not say where's the first second, only one is the first one, so this question is very strange
Pulling away, not much to say.
Going to say that trees and forests to travel around (traverse) the
Traversal trees and forests into
Depth-first traversal (DFS) and breadth-first traversal (BFS)
Which also includes the first DFS root after root order and order
Very simple, first root is the first access to the root, and then turn to access the sub-tree, the root is the first complete turn access the sub-tree root access and then finally, nothing to say, do not say
Then, the book also talked about the storage of the tree
(1) Multiple list of children notation (I wondered now textbooks do not speak vector may really have enough weak)
(2) the child Brothers notation (that is, the left child right sibling)
(3) parents notation (just to keep these points to the array, and each point can be recorded under his father, the tree does not dry inside so good .. I feel a bit loud noise when disjoint-set used ...)
Put simply look at a few pictures on the line