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的性质 ...
随机推荐
- linux配置静态ip,关闭防火墙
在vmware下安装centos6.5通过桥接方式访问外网,因此需要配置ip. 一.ip配置 1.1. 配置动态ip vi /etc/sysconfig/network-scripts/ifcfg-e ...
- java Graphics2d消除锯齿,使字体平滑显示
Java 2D API 提供的文本处理功能进行美化.Java 2D API 的文本功能包括: 使用抗锯齿处理和微调(hinting)以达到更好的输出质量 可以使用系统安装的所有字体 可以将对图形对象的 ...
- colorlog的三个例子
例1:默认的log_colors import logging from logging.handlers import RotatingFileHandler from colorlog impor ...
- XML转Map
public static Map<String, String> xmlToMap(HttpServletRequest request) throws IOException, Doc ...
- 让Android模拟器飞一会
https://software.intel.com/zh-cn/android/articles/speeding-up-the-android-emulator-on-intel-architec ...
- 使用PorterDuffXfermode画出刮刮奖效果p146-p148
package com.zzw.Qunyinzghuan3; import android.content.Context; import android.graphics.Bitmap; impor ...
- SpringCloud教程 | 第十三篇: 断路器聚合监控(Hystrix Turbine)
版权声明:本文为博主原创文章,欢迎转载,转载请注明作者.原文超链接 ,博主地址:http://blog.csdn.net/forezp. http://blog.csdn.net/forezp/art ...
- OC-SEL 和 Class
[认识选择器]============================================ SEL 1.选择器(SEL)是一个变量类型. 2.选择器用来装成员消息(成员方法) people ...
- postgresql recovery.conf改变需要重启吗
之前在研究pgpoll时,发现trigger_file参数指定的文件存在后,会自动将standby节点提升为可写节点.不需要手动执行pg_ctl promote,但是这个时间一般有延迟,因为进程会定期 ...
- DRF 的 版本,解析器,与序列化
DRF 的 版本,解析器,与序列化 补充 配置文件中的 类的调用: (字符串) v1 = ["view.xx.apth.Role","view.xx.apth.Role& ...