【PAT (Advanced Level) Practice】1086 Tree Traversals Again (25 分)
众所周知只有前序遍历和后序遍历是不可能推出中序遍历的,所以我就不废话了
由树的前序遍历和中序遍历可以推后序遍历
由树的中序遍历和后序遍历可以推前序遍历
#include <cstdio>
#include <vector>
#include <stack>
#include <cstring>
using namespace std;
vector<int> pre, in, post,value; void postorder(int root, int start, int end) {
if (start > end) return;
int i = start;
while (i < end && in[i] != pre[root]) i++;
还没有评论,来说两句吧...