A two-fork tree is created by first-order traversal and sequence traversal
1, according to the results of the sequence traversal can determine a tree.
In-sequence traversal: The result is: "12345", this "12345" can determine a tree. Please think about how many shapes there will be.
2, how to determine a tree.
Conclusion:
A tree can be determined by the sequence traversal and the first order traversal
A tree can be determined by the sequence traversal and subsequent traversal
A tree cannot be determined by first-order traversal and subsequent traversal.
Single first-order traversal: can solve the root, but can not solve the left subtree when the end of the right subtree when the start.
3, according to the first order and the result of the order of the tree painting
Algorithm
1, through the first sequence traversal to find the root node A, and then through a in the middle of the sequence of the location to find the left subtree, right subtree 2, in a left subtree, find the root node of Zuozi (in order to find), go to step 1
3, in the right subtree of a, find the root node of the right subtree (find in the order), go to step 1
Second, #号法创建二叉树
1, what is the # number method to create a tree
#创建树, let each node of the tree turn into a tree of 2 degrees.
First-order traversal: 124## #3 # # can only determine a tree, why.
#define _crt_secure_no_warnings #include <iostream> using namespace std; The first method of representation: two-chain notation typedef struct BITNODE { char data struct bitnode *lchild,*rchild
;
} bitnode,* Bitree; First-order recursive traversal void preorder (Bitnode*root) { if (root==null) { return;   printf ("%c", root->data); preorder (root->lchild); preorder (root->rchild); } //First order Create two fork Tree bitnode* createbitree () { bitnode*node = NULL; char H; &nb
sp; scanf ("%c", &h); if (h== ' # ') { return NULL; &
nbsp;} else { node = (bitnode*) malloc (sizeof (
Bitnode)); if (node==null) { & nbsp
return NULL;
  memset (node,0,sizeof (Bitnode));
node->data = h;
node->lchild = Createbitree ();
node->rchild = Createbitree ();
} return node; }//Subsequent traversal destroy binary tree void Freetree (bitnode* root) { if (root!=null) { &NBSP;&N bsp; if (root->lchild) {&
nbsp; freetree (root->lchild);
root->lchild = NULL; } if (root->rchild) {
freetree (Root->rchild);
root->rchild = NULL;  } if (root!=null) { free (root);
root=NULL;  }  } int main () { bitnode *root;
printf ("Please enter the binary tree first < such as: abdh#k## #E # #CFI # # #G #j##> to enter the return key" ");
root = Createbitree ();
//First-order traversal of the binary tree printf ("\ n-first traversal of binary tree \ n");
preorder (root);
freetree (root);
system ("pause");
return 0; }Input sequence 124## #3 # # (where the "#" means empty, and enter the process do not add a carriage return, because the carriage return also has the corresponding ASCII code, is to calculate the character, but after entering the end can press ENTER exit), this time can see the results. In addition you must manually build a binary tree, to ensure that you enter the sequence can constitute a binary tree, otherwise you how to enter, press the last number of return procedures will not end.