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的性质 ...
随机推荐
- TF卡.购买(20180925)
1.准备买 2个 一个 用于 老的手机"红米Note",一个用于现在我的手机"红米Note4X". 之前,这2个手机都是用的 那个坏掉的64g的tf卡 2.刚问 ...
- ZC_01_获取Class对象
1. package reflectionZ; public class TreflectionZ { public static void main(String[] args) throws Cl ...
- shell 数组操作
1. 定义数组: var_array=(one two three four five) 2.常用操作 获取数组长度: ${#var_array[@]} 获取所有数组元素: ${var_array[ ...
- ggplot 画 条形图
今天开会谈了半天自己的研究结果,同事皱着眉头,第一好像她没大听懂,第二感觉眼前一亮,但不知怎么落地.落地这个事情,交给时间吧,我想练熟我的分析. 今天搞了个简单的,条形图. 就是EXCEL里面经常玩的 ...
- 初试Orchard Core CMS
关于Orchard Core CMS,这是一套内容管理系统(Content Management System),看一下来自官方文档的解释,什么是Orchard CMS. Orchard is a f ...
- hive 权限:Authorization failed:No privilege 'Create' found for outputs .
创建表报错: create table test ( name string ); Authorization failed:No privilege 'Create' found for outpu ...
- Sunday算法--C#版
public static int Sunday(string text, string pattern) { int i, j, m, k; i = j = 0; int tl, pl; int p ...
- opensack-mitaka网络性能测试shaker
一.项目介绍 Shaker项目是由Mirantis发起,专门针对OpenStack网络性能的测试工具.通过模拟不同的网络场景和heat模板,创建虚拟机,并在虚拟机里运行iperf.iperf3.net ...
- 014——VUE中v-if语法在网站注册中的实际应用
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Node大文件处理
之前有个需求要将文件解析再处理,当时直接将整个文件内容读到内存中然后解析,也是没有考虑到大文件的问题,那么要如何解析大文件呢? 输入:文件的内容是多个json,按顺序排列 输出:解析后的json数据 ...