Logical structure of the tree
Tree storage structure
1. The first method of expression
In order to find sibling nodes, firstChild and right are added
The second way to express
The number of pointer fields is determined by the degree of the tree
The solution to the extra pointer domain wasting space is to
allocate several pointer domains if there are a few children, so as to avoid the pointer domain occupying space
In this way, the number of pointer fields of each node may be different due to the number of children, so it is impossible to use one node structure to represent all nodes, causing programming difficulties
The third method of expression
Child brother notation
How to find sibling nodes? How to find the child nodes through the sibling pointer
? Find the left child node through the child pointer, and then find all the right sibling nodes of the left child