1. Tree converted to two-fork tree
Each node in the tree has at most one left-most child (eldest son) and one right-neighbour brother
1) Add a connection between all the sibling nodes
2) Each node, in addition to retaining the connection to its eldest son, removes the connection to the other child
3) Level adjustment. Take the root point as the axis, the whole tree clockwise rotation of a certain angle, so that the structure of a clear hierarchy. The left child of this knot is the left child before, and the right child is the previous sibling node.
2. Forest converted to two-fork tree
1) Convert each tree to a two-fork tree.
2) The first binary tree does not move, starting from the second binary tree, in turn the root node of the second fork tree as the root node of the previous binary tree, the right child, connected with the line.
Binary tree converted to tree
is the inverse process of a tree converted to a two-fork tree.
(1) Add line. If a node x's left child node exists, then the left child's right child node, right child's right child node, right child's right child's right child knot point, all as Node x child. Connect the node x to these right child nodes using a line.
(2) Go to line. Delete all nodes in the original binary tree and their right child nodes.
(3) Level adjustment.
Binary tree converted to forest
If the root node of a binary tree has a right child, the binary tree can be converted into a forest, otherwise it will be converted to a tree.
(1) Starting from the root node, if the right child exists, then the link with the right child node is removed. Then look at the detached two-fork tree, if the right child of the root node exists, then the connection is deleted .... Until all of these root nodes are removed from the right child's connection.
(2) Convert each separated two-fork tree into a tree.
Tree, forest and two-fork tree conversion