The pre-order traversal order of the binary tree is: root node, left Tree, right tree
The central traversal order is: left Tree, root node, right tree
The descending order of traversal is: left Tree, right tree, and root node.
650) This. width = 650; "width =" 621 "Height =" 296 "style =" width: 482px; Height: 274px; "src =" http://img.blog.csdn.net/20141022130455285? Watermark/2/text/plain =/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma =/dissolve/70/gravity/center "/>
In the preceding tree, the forward traversal is: abfcjm; the forward traversal is: fbcamj; the backward traversal is: fcbmja.
The unique structure of the tree cannot be obtained based on the pre-order traversal and post-order traversal,
The two known traversal orders must include the central traversal, because the central traversal can recursively launch the left and right trees of the root node.
For the above question, we know that the forward traversal is: the forward traversal in abfcjm is: fbcamj, then we can know that the root of the tree is a according to the forward traversal,
Then, traverse through the middle order to know that the left Tree node with "A" as the root node includes FBC right Tree nodes including MJ,
Then, we can see that B is the left subnode of a according to the second node traversed in the previous order, and that the left Tree of B is F and the right tree is C according to the middle order traversal,
Repeat the preceding steps for Recursive solution to release the entire tree structure,
Finally, the order of convenience can be introduced based on the structure of the entire tree.
This article is from the "Developer" blog, please be sure to keep this source http://tang1513.blog.51cto.com/7678175/1566669
Calculate the structure of a binary tree based on the two traversal methods of the binary tree.