首页 > 其他 > 详细

堆和堆排序

时间:2014-07-18 10:23:04      阅读:289      评论:0      收藏:0      [点我收藏+]

堆有两种: max-heap 和 min-heap. Max-heap 一般用来排序,Min-heap 用来实现 priority queue.

max-heap的定义是:for each i: A[parent(i)] >= A[i]

min-heap: for each i: A[parent(i)] <= A[i]

无论要实现哪种,都会用到 Left(i), Right(i), Parent(i).

Heap-sort() 要用到的操作有:

Build-max-heap(): build a heap from an unsorted array

Max-heapify(): maintain the max-heap property 

 

Priority queue 支持的操作有:

max-priority queue:

bubuko.com,布布扣

min-priority queue 支持的操作有:insert(), minimum(), extract-min(), decrease-key()

堆和堆排序,布布扣,bubuko.com

堆和堆排序

原文:http://www.cnblogs.com/Antech/p/3852528.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!