A sequence of sequence and sequence sequences of a binary tree are known, and the only two-fork tree is defined, thereby constructing the recurrent algorithm of the binary tree.
Setting the pre-sequence sequence and the sequence sequence store two one-dimensional array, PRE (1, N), and IND (1, N), in pre-sequence sequence pre (I, j), and sequence sequence Ind (u, v) Recursively constructing a binary tree, its root node pointer is s.
TypedEf struct bnota; struct bNode * left, * right;} btree; btree * bintree (int I, int J, int u, intv) {INT K, L; BTREE * head, * s; head = null ; If (j> = i) {head = new btree; // establish root knot head-> data = pre [i]; k = u; while (ind [k]! = Pre [i]) k ///// Find root node L = I ku; // L is the position IF (k == u) // left sub-tree in the left sub-tree in the left sub-tree. -> left = null; else {s = bintree (i 1, l, u, k-1); // Construct the left subtree head-> left = S;} if (k == v) // Right Tree is empty Head-> Right = null; else {s = bintree (l 1, j, k 1, v); // Construct the right child head-> Right = S;}} RTURN head;}