1147 Heaps
1147 Heaps(30 分)
Input Specification:
Output Specification:
Sample Input:
Sample Output:
#include <cstdio>
int queryCnt,n;
];
void postOrderTraversal(int root)
{
if(root>n) return;
postOrderTraversal(root*);
postOrderTraversal(root*+);
printf("%d",CBT[root]);
) printf("\n");//因为是后序遍历,最后访问根节点,而根节点的下标固定为1
else printf(" ");
}
int main()
{
scanf("%d%d",&queryCnt,&n);
;i<queryCnt;i++){
;j<=n;j++)
scanf("%d",&CBT[j]);
//判断,层序遍历完全二叉树的非叶结点
]>CBT[]?:;//大顶堆标记为1,小顶堆标记为0。题目保证结点个数至少有两个。
;j<=n/;j++){
){
] || (j*+<=n && CBT[j]<CBT[j*+])){
flag=-;
break;
}
}
){
] || (j*+<=n && CBT[j]>CBT[j*+])){
flag=-;
break;
}
}
}
) printf("Max Heap\n");
) printf("Min Heap\n");
else printf("Not Heap\n");
//输出后续序列
postOrderTraversal();
}
;
}
1147 Heaps的更多相关文章
- PAT 1147 Heaps[难]
1147 Heaps(30 分) In computer science, a heap is a specialized tree-based data structure that satisfi ...
- [PAT] 1147 Heaps(30 分)
1147 Heaps(30 分) In computer science, a heap is a specialized tree-based data structure that satisfi ...
- PAT 甲级 1147 Heaps (30 分) (层序遍历,如何建树,后序输出,还有更简单的方法~)
1147 Heaps (30 分) In computer science, a heap is a specialized tree-based data structure that sati ...
- PAT 1147 Heaps
https://pintia.cn/problem-sets/994805342720868352/problems/994805342821531648 In computer science, a ...
- 1147. Heaps (30)
In computer science, a heap is a specialized tree-based data structure that satisfies the heap prope ...
- PAT甲级——1147 Heaps【30】
In computer science, a heap is a specialized tree-based data structure that satisfies the heap prope ...
- PAT Advanced 1147 Heaps (30) [堆,树的遍历]
题目 In computer science, a heap is a specialized tree-based data structure that satisfies the heap pr ...
- PAT (Advanced Level) 1144~1147:1145Hash二次探查 1146拓扑排序 1147堆
1144 The Missing Number(20 分) 题意:给定N个数的序列,输出不在序列中的最小的正整数. 分析: 1.给定的N个数可能为正,可能为负,可能重复. 2.由于N≤105,所 ...
- PAT甲级目录
树(23) 备注 1004 Counting Leaves 1020 Tree Traversals 1043 Is It a Binary Search Tree 判断BST,BST的性质 ...
随机推荐
- Spring Boot的核心
1.1.1. 入口类和@SpringBootApplication Spring Boot的项目一般都会有*Application的入口类,入口类中会有main方法,这是一个标准的Java应用程序 ...
- SQL优化器执行过程之逻辑算子
我们提到了两种SQL优化器,分别是RBO和CBO.那么无论是RBO,还是CBO都包含了一系列优化规则,这些优化规则可以对关系表达式进行等价转换,从而寻找最优的执行计划. 那么常见的优化规则就包括: 列 ...
- MFC--自定义CMFCTabCtrl的实现
在MFC实现桌面程序时,可能会用到TabView效果,我实现的是最基本的效果,如下图: 下面介绍详细的实现过程,如果需要效果更好看些,自行美化. 1. 创建自定义MFCTabCtrl类MyMFCTa ...
- Xcode 8 GM 编译缺失 /Users/usr/lib/libresolv.9.dylib
原因是操作系统的文件与手机需要的不同. 解决办法是将iOS DeviceSupport里当前手机版本的Symbols的libresolv.9.dylib文件,代替编译失败项目的Build Phases ...
- 19-THREE.JS 深度材质
<!DOCTYPE html> <html> <head> <title></title> <script src="htt ...
- sql语句判断 case when用法
sql语句判断方法之一 selectcase when t.bk1='on' then 1else 0 end as 基础 ,case when t.bk2='on' then 1else 0 en ...
- tf随笔-6
import tensorflow as tfx=tf.constant([-0.2,0.5,43.98,-23.1,26.58])y=tf.clip_by_value(x,1e-10,1.0)ses ...
- 目标跟踪之相关滤波:CF及后续改进篇
一. 何为相关滤波? Correlation Filter 最早应用于信号处理,用来描述两个信号之间的相关性,或者说相似性(有点像早期的概率密度),先来看定义: 对于两个数据 f 和 g,则两个信号的 ...
- Django之jango框架 及 APP
Django框架 MVC框架和MTV框架 MVC,全名是Model View Controller,是软件工程中的软件架构模式,把软件系统分为三个基本部分:模型(Model).视图(View)和控制器 ...
- iOS开发单例模式 dispatch_once
什么是单例 单例模式是一种常用的软件设计模式.在它的核心结构中只包含一个被称为单例类的特殊类.通过单例模式可以保证系统中一个类只有一个实例而且该实例易于外界访问,从而方便对实例个数的控制并节约系统资源 ...