18年春季第四题 PAT甲级 1147 Heaps (30分) 可以不建树

这篇博客介绍了如何判断一个完全二叉树是否为堆,包括最大堆和最小堆,并提供了相关知识点和解题思路。内容涉及堆的定义、层序遍历和后序遍历,以及如何通过深度优先搜索实现后序遍历序列的生成。同时,博主分享了PAT甲级考试中关于堆的题型特点和备考建议。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

汇总贴

2020年3月PAT甲级满分必备刷题技巧

题目

来源:https://pintia.cn/problem-sets/994805342720868352/problems/994805342821531648

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (in a max heap) or less than or equal to (in a min heap) the key of C. A common implementation of a heap is the binary heap, in which the tree is a complete binary tree. (Quoted from Wikipedia at https://en.wikipedia.org/wiki/Heap_(data_structure))

Your job is to tell if a given complete binary tree is a heap.

Input Specification:

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值