1064. Complete Binary Search Tree
二叉排序树:
http://www.patest.cn/contests/pat-a-practise/1064
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std; int ans[]; int cnt = ; void inoder(vector<int> vv,int x,int n)
{
if(*x <= n)
{
inoder(vv,*x,n);
}
ans[x] = vv[cnt++];
if(*x + <= n)
{
inoder(vv,*x +,n);
}
} int main()
{
int n,tem;
vector<int> vv;
cin >> n;
int i = n;
while(i--)
{
cin >> tem;
vv.push_back(tem);
}
sort(vv.begin(),vv.end());
inoder(vv,,n);
bool fir = ;
for(i = ; i <= n ;++i)
{
if(fir)
{
fir = ;
cout << ans[i];
}
else
{
cout << " " << ans[i];
}
}
cout << endl;
return ;
}
1064. Complete Binary Search Tree的更多相关文章
- PAT题库-1064. Complete Binary Search Tree (30)
1064. Complete Binary Search Tree (30) 时间限制 100 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...
- PAT 1064 Complete Binary Search Tree[二叉树][难]
1064 Complete Binary Search Tree (30)(30 分) A Binary Search Tree (BST) is recursively defined as a b ...
- pat 甲级 1064. Complete Binary Search Tree (30)
1064. Complete Binary Search Tree (30) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...
- 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 ...
- PAT 甲级 1064 Complete Binary Search Tree (30 分)(不会做,重点复习,模拟中序遍历)
1064 Complete Binary Search Tree (30 分) A Binary Search Tree (BST) is recursively defined as a bin ...
- pat 甲级 1064 ( Complete Binary Search Tree ) (数据结构)
1064 Complete Binary Search Tree (30 分) A Binary Search Tree (BST) is recursively defined as a binar ...
- PAT甲级:1064 Complete Binary Search Tree (30分)
PAT甲级:1064 Complete Binary Search Tree (30分) 题干 A Binary Search Tree (BST) is recursively defined as ...
- PAT 甲级 1064 Complete Binary Search Tree
https://pintia.cn/problem-sets/994805342720868352/problems/994805407749357568 A Binary Search Tree ( ...
- 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 ...
- 1064 Complete Binary Search Tree (30分)(已知中序输出层序遍历)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following propertie ...
随机推荐
- Steps to disable DRLs with GM Tech2 scanner
It is possible to get daytime running time disabled manually. But the problem can be easily settled ...
- uva 784 Maze Exploration 染色 搜索水题 DFS
染色问题,其实就是看看图上某一点能扩散多少. 用DFS解决,因为BFS不是很熟 =-=...以后要多练. 提交后32ms,优化了一下,在递归前进行判定,优化到22ms,不是优化的很好... 代码: # ...
- js判断图片上传时的文件大小,和宽高尺寸
今天在做图片上传的小功能,使用了一个kissy上传组件.很好奇它是如何在图片上传前,检测到图片的大小和尺寸的?我们来写个小实例实现一下吧 如何读取图片的size 首先,原生input file控件有个 ...
- 关于Linux的总结(二)
主要内容 Linux 安装 常用命令 VI编辑器的使用 远程登录 主机名的设置 IP的设置 防火墙的设置 用户和组账户管理 文件权限管理 RPM软件包管理 软件的安装 Jdk,tomcat, ecli ...
- 转:java服务器安全指南
转: http://drops.wooyun.org/web/16609 JAVA安全之JAVA服务器安全漫谈 z_zz_zzz · 2016/06/08 10:50 0x00 前言 本文主要针对JA ...
- C# 按指定数量从前面或者后面删除字符串
为了方便处理一些数据,自己写一个小程序来辅助工作,提高点效率. 不够删除怎么办呢!?一般程序员都会马上想到的是,用if判断…….这里其实不用if语句也可以轻松实现的! 有些程序员还可能用 try c ...
- JavaScript基础笔记一
一.真假判断 真的:true.非零数字.非空字符串.非空对象 假的:false.数字零.空字符串.空对象.undefined 例: if(0){ alert(1) }else{ alert(2) } ...
- javascript+dom 做javascript图片库
废话不多说 直接贴代码 <!DOCTYPE html><html lang="en"><head> <meta charset=" ...
- Jersey(1.19.1) - Hello World, Get started with Jersey using the embedded Grizzly server
Maven Dependencies The following Maven dependencies need to be added to the pom: <dependency> ...
- C# 好书一本推荐
书名<CLR Via C#>第三版中文版,我已上传: 下载地址:http://files.cnblogs.com/jackchiang/CLR_Via_Csharp.%E7%AC%AC3% ...