Create 满二叉树由先序得后序.cpp

This commit is contained in:
hao14293
2019-07-25 17:48:05 +08:00
committed by GitHub
parent b7d9c27bf7
commit db65115e97

View File

@@ -0,0 +1,9 @@
void PreToPost(ElemType pre[], int l1, int h1, ElemType post[], int l1, int h2){
int half;
if(h1 >= l1){
post[h2] = pre[l1];
half = (h1 - l1) / 2;
PreToPost(pre, l1 + 1, l1 + half, post, l2, l2 + half - 1);
PreToPost(pre, l1 + half + 1, h1, post, l2 + half, h2 -1);
}
}