学习自博主的文章,感谢!
目录
前序、中序、后序的遍历顺序
小圆圈是当前子树的根节点
例子:
前序+中序 -> 后序
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <queue>
using namespace std;
const int maxn =505;
typedef struct node{
struct node *lchild;
struct node *rchild;
char data;
}node,*tree;
int cur,n;
char pre[maxn],in[maxn];
int find(char x)//找出中序遍历中该节点的位置
{
for(int i = 0;i < n;i++)
if(in[i] ==