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的性质 ...
随机推荐
- D3.js学习笔记(三)——创建基于数据的SVG元素
目标 在这一章,你将会使用D3.js,基于我们的数据来把SVG元素添加到网页中.这一过程包括:把数据绑定到元素上,然后在使用这些元素来可视化我们的数据. 注意:不同于前几章,我们从一个完整的代码开始, ...
- spring3: 基于Schema的AOP
6.3 基于Schema的AOP 基于Schema的AOP从Spring2.0之后通过“aop”命名空间来定义切面.切入点及声明通知. 在Spring配置文件中,所以AOP相关定义必须放在<a ...
- RabbitMQ C# driver stops receiving messages
http://stackoverflow.com/questions/12499174/rabbitmq-c-sharp-driver-stops-receiving-messages
- python中sorted()函数的用法
一. 定义 sorted()函数对所有可迭代的对象进行排序操作 二. 语法 sorted(iterable [, key[, reverse]]]) iterable:可迭代对象 key:主要是用来进 ...
- 三十三 Python分布式爬虫打造搜索引擎Scrapy精讲—数据收集(Stats Collection)
Scrapy提供了方便的收集数据的机制.数据以key/value方式存储,值大多是计数值. 该机制叫做数据收集器(Stats Collector),可以通过 Crawler API 的属性 stats ...
- 51nod 1640 MST+二分
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1640 1640 天气晴朗的魔法 题目来源: 原创 基准时间限制:1 秒 ...
- IOS-社会化分享
一.如何实现社交分享 在iOS中,实现“社交分享”的方法 1.自己编写各个平台的分享代码(代码量较多) 2.利用iOS自带的Social.framework 3.利用第三方的分享框架 友盟分享 ...
- 【spark】分区
RDD是弹性分布式数据集,通常RDD很大,会被分成多个分区,保存在不同节点上. 那么分区有什么好处呢? 分区能减少节点之间的通信开销,正确的分区能大大加快程序的执行速度. 我们看个例子 首先我们要了解 ...
- 【2018年全国多校算法寒假训练营练习比赛(第四场)-A】石油采集(匈牙利算法)
试题链接:https://www.nowcoder.com/acm/contest/76/A [思路] 每个‘#’的右边和下边如果也是‘#’说明这两个点构成通路,以此重构一幅图,然后找二分图的最大匹配 ...
- Spring AOP(面向切面示例)
什么是AOP?基本概念切面(aspect):横切关注点被模块化的特殊对象.通知(advice):切面必须要完成的工作.切面中的每个方向称之为通知.通知是在切面对象中的.目标(target):被通知的对 ...