There are three types of binary tree traversal: pre-order, in-order, and post-order, of which in-order traversal is the most important. Why is it called this name? are named according to the order of the root node.
For example, a normal full node in the above figure, A: root node, B: left node, C: right node, the pre-order order is ABC (the root node is first, then the same level is left and then right); the middle order is BAC (first left, then root, last right); post-order sequence is BCA (first left, then right, last root).
For example, the binary tree traversal result in the above figure
Preorder traversal: ABCDEFGHK
In-order traversal: BDCAEHGKF
Post-order traversal: DCBHKGFEA
Analyze the in-order traversal as shown in the figure below, the in-order is more important (many tree sorting in java is based on in-order, and the analysis will be explained later)