![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
堆
文章平均质量分 66
zadarmo_
这个作者很懒,什么都没留下…
展开
-
堆和堆排序
堆是一种优先队列,堆有两个特性: 结构性:用数组表示的完全二叉树; 有序性:任一结点的关键字是其子树所有结点的最值。如果是最大值,则成为最大堆;如果是最小值,称为最小堆。 基于第一个特性,可以用一个一维数组去存这个堆,起始下标为1。 对于堆的操作,下面只给出最大堆的插入和删除的操作。 插入元素 如图所示: 其主要思想是: 先将元素放入数组的最后一个位置 将这个元素进行向上调整 代码如下...原创 2019-08-04 17:24:05 · 156 阅读 · 0 评论 -
1147 Heaps (30 分)——甲级(堆)
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 (i...原创 2019-08-17 13:35:53 · 90 阅读 · 0 评论 -
1155 Heap Paths (30 分)——甲级(堆+dfs回溯)
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 (i...原创 2019-08-17 14:06:29 · 151 阅读 · 0 评论