struct Node{
int value;
Node* left;
Node* right;
};
int N, postord[30], midord[30];
Node* ConstructTree(int post_head, int post_tail, int mid_head, int mid_tail){
if(post_head>post_tail) return NULL;
//根据后序序列区间和中序序列区间构建二叉树,返回根节点的指针
Node* root = new Node;
root->value = postord[post_tail];
int index;//根节点在中序序列中的位置
for(index=mid_head; midord[index]!=postord[post_tail]; index++);
//左子树的节点个数
int left_len = index-mid_head;
//左子树
root->left = ConstructTree(post_head, post_head+left_len-1, mid_head, index-1);
//右子树
root->right = ConstructTree(post_head+left_len, post_tail-1, index+1, mid_tail);
return root;
}
int main(){
cin >> N;
for(int i=0; i<N; i++) cin >> postord[i];
for(int i=0; i<N; i++) cin >> midord[i];
Node* root = ConstructTree(0, N-1, 0, N-1);
queue<Node*> que;
bool isRoot = true;
que.push(root);
while(!que.empty()){
Node* np = que.front();
if(!isRoot) cout << " ";
isRoot = false;
cout << np->value;
if(np->left) que.push(np->left);
if(np->right) que.push(np->right);
que.pop();
}
}
[
![](https://img-blog.csdnimg.cn/92aabf6b0d3144eaa7da7155d56e35de.jpeg)
开发者涨薪指南 ![](https://img-blog.csdnimg.cn/img_convert/b62c48a4d49b4ab51bd2febac71fcc9f.png)
48位大咖的思考法则、工作方式、逻辑体系
](https://blog.csdn.net/programmer_editor/article/details/124704548?utm_campaign=marketingcard&utm_source=Dae_Lzh&utm_content=122843350)
**自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。**
**深知大多数Python工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!**
**因此收集整理了一份《2024年Python开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。**
![img](https://img-blog.csdnimg.cn/img_convert/5fe2909dae1cae816251f90de48a9d34.png)
![img](https://img-blog.csdnimg.cn/img_convert/4ef7cde8c9087e64f4a346a7a0dd4ffb.png)
![img](https://img-blog.csdnimg.cn/img_convert/33677995154c9db861d9c15457f26614.png)
![img](https://img-blog.csdnimg.cn/img_convert/8da5f87783951ba3cc90491d673245b2.png)
![img](https://img-blog.csdnimg.cn/img_convert/6c361282296f86381401c05e862fe4e9.png)
![img](https://img-blog.csdnimg.cn/img_convert/9f49b566129f47b8a67243c1008edf79.png)
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!**
**由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新**
**如果你觉得这些内容对你有帮助,可以扫码获取!!!(备注:Python)**
入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!**
**由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新**
**如果你觉得这些内容对你有帮助,可以扫码获取!!!(备注:Python)**
![](https://img-blog.csdnimg.cn/img_convert/b6f62d000717591bb2de62d6f23b6d49.jpeg)