Question: enter two groups of data, namely the pre-order traversal sequence and the middle-order traversal sequence, you need to write a program to use these two sets of data to find the post-order traversal sequence of the tree (pre-order sequence + middle-order sequence = post-order sequence) solution: recursive question analysis: you can first export the post-order sequence in the form of pen and paper. The derivation process is omitted. During the derivation, we will find the rule: assume that the pre-order sequence is a B e h f c g I, and the pre-order sequence is h e B f a c I G (as shown in the figure below, extract letters in order to split the central sequence and traverse the characters in the middle sequence. The left and right Subtrees are separated. (Note that they are also Binary Trees !) Like this: Take A, the middle sequence is divided into left subtree: h e B f right subtree c I g continue to take B, but this time is for left subtree: separate h e B F. The split result is: Left subtree: h e right subtree B F until it can no longer be split, recursion will return to the right subtree separated by A for the first time. The entire process above will be recursive. Therefore, the code will be better understood once combined with pen strokes: [cpp] # include <stdio. h> # include <stdlib. h> typedef struct TreeNode {char data; struct TreeNode * lchild; struct TreeNode * rchild;} Node, * PNode; char preorder [28]; // store the preordered char infix [28]; // store the ordinal char * Pr; void build (char * in, char * pr, PNode * tr ); void postordertraversal (PNode T); int main () {// first build, PNode T; while (scanf ("% s", & preorder [1], & infix [1]) = 2) {build (& infix [1], & preorder [1], & T); postordertraversal (T); printf ("\ n");} return 0 ;} void build (char * in, char * pr, PNode * tr) {char * p = in; Pr = pr; if (* in = 0) {* tr = NULL; return;} while (1) {if (* in = * Pr) {(* tr) = (PNode) malloc (sizeof (Node); (* tr) -> data = * Pr; * in = 0; break;} in ++;} Pr = Pr + 1; build (p, Pr, & (* Tr)-> lchild); build (in + 1, Pr, & (* tr)-> rchild);} void postordertraversal (PNode T) {if (T = NULL) return; postordertraversal (T-> lchild); postordertraversal (T-> rchild); printf ("% c", T-> data );} note some things in this Code: pointers are used here, But pointers are not actually used. The more elaborate solution described below is to use the lower mark. If you do not need a pointer, try not to pay attention to the role of the pointer here. Here we will explain the above solution, which is easy to think of, so the code is not very delicate. There is a better solution here!