当前位置:网站首页>7-2 construction of binary tree by post order + middle order sequence
7-2 construction of binary tree by post order + middle order sequence
2022-06-24 23:31:00 【White -】
7-2 In the following order + Construction of binary tree by middle order sequence
In the following order + Construction of binary tree by middle order sequence
sample input :
First line input sequence length n, Second line input n Characters represent the sequence of post order traversal of binary tree , In the third line, enter n Characters represent the sequence of ordinal traversal in a binary tree
9
GHDBEIFCA
GDHBAECIF
sample output :
Output binary tree preorder traversal sequence .
ABDGHCEFI
Code :
#include <stdio.h>
#include <stdlib.h>
int n;
void CreatTree(int n,char after[],char mid[])
{
if(n<0)
return ;
else
{
printf("%c",after[n]);
int i;
for(i=0;i<=n;i++)
{
if(mid[i]==after[n])
break;
}
CreatTree(i-1,after,mid);
CreatTree(n-i-1,after+i,mid+i+1);
return ;
}
}
int main()
{
char after[1000];
char mid[1000];
scanf("%d",&n);
scanf("%s",after);
scanf("%s",mid);
CreatTree(n-1,after,mid);
return 0;
}
202206222111 3、 ... and
边栏推荐
- Ningde times will increase RMB 45billion: Hillhouse subscribes RMB 3billion and Zeng Yuqun still controls 23% of the equity
- 第六章 网络学习相关技巧5(超参数验证)
- Latest development of jetpack compose
- Ganglia 的安装与部署
- throttle-debounce.js:一个小型的防抖节流函数库
- 伪原创智能改写api百度-收录良好
- golang convert map to json string
- Helix distance of point
- Inventory of data governance status of six major banks: governance architecture, data standards and data middle office (April 2022)
- Websocket long link pressure test
猜你喜欢

点的螺旋距离

【基础知识】~ 半加器 & 全加器

SimpleDateFormat 格式化和解析日期的具体类

明天就是PMP考试了(6月25日),这些大家都了解了吗?
![[JS] - [stack, team - application] - learning notes](/img/5b/b90ed8d3eb4fc0ab41c6ea8d092d0f.png)
[JS] - [stack, team - application] - learning notes

Main cause of EMI - mold current

第六章 网络学习相关技巧5(超参数验证)
![[JS] - [array, stack, queue, linked list basics] - Notes](/img/c6/a1bd3b8ef6476d7d549abcb442949a.png)
[JS] - [array, stack, queue, linked list basics] - Notes

Actipro WPF Controls 2022.1.2

Detailed explanation of online group chat and dating platform project (servlet implementation)
随机推荐
Docker-mysql8-master-slave
7-2 求解买股票问题
2021-2022 China's financial digitalization "new" insight Industry Research Report
R language dplyr package group_ By function and summarize_ The at function calculates the dataframe to calculate the number of counts and the mean value of different groups (summary data by category v
[JS] - [stack, team - application] - learning notes
R language uses the polR function of mass package to build an ordered multi classification logistic regression model, and uses exp function, confint function and coef function to obtain the confidence
Common regular expressions
Bubble sort
【js】-【数组应用】-学习笔记
7-6 铺设油井管道
[JS] - [tree] - learning notes
idea创建模块提示已存在
R语言使用epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息、自定义FUN参数为多个统计量函数名称的列表计算多个统计量
【js】-【字符串-应用】- 学习笔记
golang convert map to json string
Gocolly manual
HarmonyOS访问数据库实例(3)--用ORM Bee测下HarmonyOS到底有多牛
[JS] - [array, Stack, queue, Link List basis] - Notes
RT-thread使用rt-kprintf
7-7 数字三角形