mirror of
https://github.com/hao14293/2021-Postgraduate-408.git
synced 2026-06-14 22:26:49 +08:00
Create 满二叉树由先序得后序.cpp
This commit is contained in:
9
DailySummary/满二叉树由先序得后序.cpp
Normal file
9
DailySummary/满二叉树由先序得后序.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user