Storage structure of 5.5.1 tree
The tree's storage structure is usually represented in the following three ways.
1. Parental representation
This storage structure is convenient for the parent (or ancestor including the root) of the specified node.
In this storage notation, however, children or other descendants of the specified node may need to traverse the entire structure.
2. Child Linked List method
In contrast to parental representations, the child's linked-list notation facilitates the implementation of operations involving child nodes, and does not apply to the operation of the parent (t,x).
3. Child Brother representation
The biggest advantage of this storage structure is that it is exactly the same as the two-fork list of the two-fork tree, so you can use the various algorithms of the binary tree to implement the tree operation.
Transformation of 5.5.2 tree, forest and two-fork tree
Tree, forest to two fork tree conversion
We know that each node in the tree has at most only one leftmost child (the eldest son) and one right neighbour's brother, according to this relationship, you can convert a tree into a binary tree by the following method: First, add a line between all the sibling nodes, and then keep the line of the eldest son on each node, removing the knot from the other child. Since the roots have no brothers, the right subtree of the root node of the transformed two-tree will be empty.
The way to convert a forest into a two-tree is to first convert each tree in the forest into a binary tree, and then treat the root nodes of each of the two-forked trees as brothers together, forming a tree
Two-pronged tree.
5.5 Trees and forests