資料結構實驗之二叉樹八 (中序後序)求二叉樹的深度

2021-08-10 03:54:25 字數 762 閱讀 1110

time limit: 1000ms

memory limit: 65536kb

submit

statistic

problem description

已知一顆二叉樹的中序遍歷序列和後序遍歷序列,求二叉樹的深度。

input

輸入資料有多組,輸入t,代表有t組資料。每組資料報括兩個長度小於50的字串,第乙個字串表示二叉樹的中序遍歷,第二個表示二叉樹的後序遍歷。

output

輸出二叉樹的深度。

example input

2

dbgeafc

dgebfca

lnixu

linux

example output

4

3

#include #include #include typedef struct node*bittree;

int cnt = 0;

char str[100];

/*void rebuild(bittree &root, char xianxu, char zhongxu)

i++;

}}*/bittree rebuild(char *a, char *b, int n)

int depth(bittree root)

return 0;

}int main()

return 0;

}

資料結構實驗之二叉樹八 (中序後序)求二叉樹的深度

problem description 已知一顆二叉樹的中序遍歷序列和後序遍歷序列,求二叉樹的深度。input 輸入資料有多組,輸入t,代表有t組資料。每組資料報括兩個長度小於50的字串,第乙個字串表示二叉樹的中序遍歷,第二個表示二叉樹的後序遍歷。output 輸出二叉樹的深度。example in...

資料結構實驗之二叉樹八 (中序後序)求二叉樹的深度

time limit 1000ms memory limit 65536kb submit statistic problem description 已知一顆二叉樹的中序遍歷序列和後序遍歷序列,求二叉樹的深度。input 輸入資料有多組,輸入t,代表有t組資料。每組資料報括兩個長度小於50的字串,...

資料結構實驗之二叉樹八 (中序後序)求二叉樹的深度

time limit 1000ms memory limit 65536kb submit statistic problem description 已知一顆二叉樹的中序遍歷序列和後序遍歷序列,求二叉樹的深度。input 輸入資料有多組,輸入t,代表有t組資料。每組資料報括兩個長度小於50的字串,...