算法竞赛入门经典177页,二叉树遍历,水题
题目意思:
给出先序和中序,求后序
本题要点:
1、 一个二叉树的先序和中序,确定一颗唯一的二叉树。
2、写一个递归,由先序和中序建立一颗二叉树
3、再写一个递归,后序遍历二叉树,打印每一节点。
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int MaxN = 30;
char pre[MaxN], mid[MaxN];
struct node
{
char ch;
node* left;
node* right;
};
node* build(int l1, int r1, int l2,