中序遍历建树

#include<bits/stdc++.h>

using namespace std;
const int N=1e3+;
int s[N];
int n;
int tree[N];
int cnt;
void inorder(int root)
{
if(root>n) return;
inorder(root*);
tree[root]=s[cnt++];
inorder(root*+);
}
int main()
{
scanf("%d",&n);
for(int i=;i<n;i++) scanf("%d",&s[i]);
sort(s,s+n);
inorder();
for(int i=;i<=n;i++){
if(i!=) printf(" ");
printf("%d",tree[i]);
}
return ;
}

1064 Complete Binary Search Tree (30 分)(二叉查找树)的更多相关文章

  1. PAT 甲级 1064 Complete Binary Search Tree (30 分)(不会做,重点复习,模拟中序遍历)

    1064 Complete Binary Search Tree (30 分)   A Binary Search Tree (BST) is recursively defined as a bin ...

  2. PAT甲级:1064 Complete Binary Search Tree (30分)

    PAT甲级:1064 Complete Binary Search Tree (30分) 题干 A Binary Search Tree (BST) is recursively defined as ...

  3. 1064 Complete Binary Search Tree (30分)(已知中序输出层序遍历)

    A Binary Search Tree (BST) is recursively defined as a binary tree which has the following propertie ...

  4. 【PAT甲级】1064 Complete Binary Search Tree (30 分)

    题意:输入一个正整数N(<=1000),接着输入N个非负整数(<=2000),输出完全二叉树的层次遍历. AAAAAccepted code: #define HAVE_STRUCT_TI ...

  5. PAT题库-1064. Complete Binary Search Tree (30)

    1064. Complete Binary Search Tree (30) 时间限制 100 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...

  6. pat 甲级 1064. Complete Binary Search Tree (30)

    1064. Complete Binary Search Tree (30) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...

  7. PTA 04-树6 Complete Binary Search Tree (30分)

    题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/669 5-7 Complete Binary Search Tree   (30分) A ...

  8. 1064. Complete Binary Search Tree (30)【二叉树】——PAT (Advanced Level) Practise

    题目信息 1064. Complete Binary Search Tree (30) 时间限制100 ms 内存限制65536 kB 代码长度限制16000 B A Binary Search Tr ...

  9. PAT Advanced 1064 Complete Binary Search Tree (30) [⼆叉查找树BST]

    题目 A Binary Search Tree (BST) is recursively defined as a binary tree which has the following proper ...

  10. 04-树6 Complete Binary Search Tree (30 分)

    A Binary Search Tree (BST) is recursively defined as a binary tree which has the following propertie ...

随机推荐

  1. C++STL之multiset多重集合容器

    multiset多重集合容器 multiset与set一样, 也是使用红黑树来组织元素数据的, 唯一不同的是, multiset允许重复的元素键值插入, 而set则不允许. multiset也需要声明 ...

  2. AngularJS 控制器的方法

    AngularJS 控制器也有方法(变量和函数) <!DOCTYPE html><html><head><meta http-equiv="Cont ...

  3. Java框架 面试题总结

    一. Struts1.x 4 1. struts1优缺点,为什么要使用struts1 4 2. Struts1核心组件 4 3. Strust1请求处理流程  工作原理 4 4. Struts1线程安 ...

  4. 使用nsis开发自定义安装包使用心得,以及遇到坑

    因为新公司需要开发pc应用的自定义安装包,开始时候计划使用nsis开发,论坛上面有很多不错的例子,而且完成度很强, 随便拿来修改使用,但是后续的开发过程中遇到的问题就逐个出现. 首先说一下nsis的优 ...

  5. UVA_10820_send a table

    When participating in programming contests, you sometimes face the following problem: You know how t ...

  6. ssm整合-错误

    [Err] 1005 - Can't create table 'imoocdb.ec_article' (errno: 150) 这个错误由外键约束引起的 java.lang.ClassCastEx ...

  7. opencms研究笔记

    最近公司一新产品,众多选型之后: 最后还是准备在用opencms 在opencms的基础上,进行二次开发: 有一起研究的没 欢迎交流:

  8. laravel查看执行的sql语句

    方法一: 我们有时候想测试一段代码生产的 SQL 语句,比如: 我们想看 App\User::all(); 产生的 SQL 语句,我们简单在 routes.php 做个实验即可: //app/Http ...

  9. 微信小程序禁止下拉_解决小程序下拉出现空白的情况

    微信小程序禁止下拉 在微信小程序中,用力往下拉动,页面顶部会出现一段空白的地方. 产品的需求不太允许这么做,会影响用户体验,查看文档发现可以使用enablePullDownRefresh这属性来实现, ...

  10. linux socketpair

    相对于无名管道来说,socketpair也是使用在亲缘进程之间,不过它提供了能够全双工通信的通道 man socketpair: #include <sys/types.h> /* See ...