参考文章:点一下
1.通过前序序列和中序序列建立二叉树
#include<bits/stdc++.h>
using namespace std;
typedef struct node{
char data;
struct node *left;
struct node *right;
}Tree;
string a;
string b;
//根据前序和中序建立二叉树
Tree *bulid(int l1,int l2,int r1,int r2)
{
if(l1>l2)
{
return NULL;
}
Tree *root=new Tree();
root->data=a[l1];
int p=0;
while(root->data!=b[p])
{
p++;
}
int llem=p-r1