当前位置:网站首页>Uva536 binary tree reconstruction tree recovery
Uva536 binary tree reconstruction tree recovery
2022-07-04 12:25:00 【Harmful Poems】
Enter the sequence of preorder traversal and middle order traversal of a binary tree , Output its post order traversal sequence .
#include<bits/stdc++.h>
using namespace std;
string preorder,inorder;
void postorder(string pre,string in){
if(pre.size() <= 0){
return ;
}
int len = 0;
len = in.find(pre[0]);
postorder(pre.substr(1,len),in.substr(0,len));
postorder(pre.substr(len+1).in.substr(len+1));
cout<<pre[0];
}
int mian(){
while(cin>>preorder>>inorder){
postorder(preorder,inorder);
cout<<endl;
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
string preorder,inorder;
void postorder(int l1,int l2,int n){
if(n <= 0){
return ;
}
int len = 0;
int len = inorder.find(preorder[l1]) - l2;
postorder(l1+1,l2,len);
postorder(l1+len+1,l2+len+1,n-len-1);
cout<<preorder[l1];
}
int mian(){
while(cin>>preorder>>inorder){
int len = preorder.size();
postorder(0,0,len);// Preamble start subscript , Middle order start subscript , length
cout<<endl;
}
return 0;
}
边栏推荐
- Single spa, Qiankun, Friday access practice
- 8.8.1-PointersOnC-20220214
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 23
- TCP fast retransmission sack mechanism
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 19
- . Does net 4 have a built-in JSON serializer / deserializer- Does . NET 4 have a built-in JSON serializer/deserializer?
- SAP ui5 date type sap ui. model. type. Analysis of the display format of date
- QQ group administrators
- Ternsort model integration summary
- Force buckle 142 Circular linked list II
猜你喜欢
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15](/img/72/0fe9cb032339d5f1ccf6f6c24edc57.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15

The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20](/img/d5/4bce239b522696b5312b1346336b5f.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20

Reptile learning winter vacation series (2)

Awk getting started to proficient series - awk quick start

Hongke case study on storm impact in coastal areas of North Carolina using lidar

Automatic translation between Chinese and English

Realize cross tenant Vnet connection through azure virtual Wan

Memory computing integration: AI chip architecture in the post Moorish Era

ASP. Net razor – introduction to VB loops and arrays
随机推荐
Recommend a cool geospatial data visualization tool with low code
OSI model notes
Source code analysis of the implementation mechanism of multisets in guava class library
Btrace tells you how to debug online without restarting the JVM
[solve the error of this pointing in the applet] SetData of undefined
What if the chat record is gone? How to restore wechat chat records on Apple Mobile
MySQL performance optimization index
Configure SSH key to realize login free
Xiaobing · beauty appraisal
Four sorts: bubble, select, insert, count
[directory] search
Openssl3.0 learning 20 provider KDF
Leetcode: 408 sliding window median
Azure solution: how can third-party tools call azure blob storage to store data?
MPLS experiment
Simple understanding of seesion, cookies, tokens
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 23
LxC shared directory addition and deletion
DVC use case (VI): Data Registry