problem description
已知一棵二叉樹的中序遍歷和後序遍歷,求二叉樹的先序遍歷
input
輸入資料有多組,第一行是乙個整數t (t<1000),代表有t組測試資料。每組包括兩個長度小於50 的字串,第乙個字串表示二叉樹的中序遍歷序列,第二個字串表示二叉樹的後序遍歷序列。
output
輸出二叉樹的先序遍歷序列
example input
2dbgeafc
dgebfca
lnixu
linux
example output
abdegcfxnliu
01
#include
02
#include
03
#include
04
char
a[10010], b[10010];
05
struct
node
06
;
10
struct
node *creat(
int
n,
char
a,
char
b)
11
21
root->l = creat(i, a, b);
22
root->r = creat(n-1-i, a+i+1, b+i);
23
return
root;
24
}
25
void
order(
struct
node *root)
26
33
}
34
int
main()
35
47
return
0;
48
}
求二叉樹的先序遍歷
time limit 1000ms memory limit 65536k 已知一棵二叉樹的中序遍歷和後序遍歷,求二叉樹的先序遍歷 輸入資料有多組,第一行是乙個整數t t 1000 代表有t組測試資料。每組包括兩個長度小於50 的字串,第乙個字串表示二叉樹的中序遍歷序列,第二個字串表示二叉樹的後序遍...
求二叉樹的先序遍歷
time limit 1000ms memory limit 65536k 有疑問?點這裡 已知一棵二叉樹的中序遍歷和後序遍歷,求二叉樹的先序遍歷 輸入資料有多組,第一行是乙個整數t t 1000 代表有t組測試資料。每組包括兩個長度小於50 的字串,第乙個字串表示二叉樹的中序遍歷序列,第二個字串表...
求二叉樹的先序遍歷
已知一棵二叉樹的中序遍歷和後序遍歷,求二叉樹的先序遍歷 輸入資料有多組,第一行是乙個整數t t 1000 代表有t組測試資料。每組包括兩個長度小於50 的字串,第乙個字串表示二叉樹的中序遍歷序列,第二個字串表示二叉樹的後序遍歷序列。輸出二叉樹的先序遍歷序列 2 dbgeafc dgebfca lni...