CLRS:max_heap and min_heap operation (pseudocode)
//max_heap
heap_maximum:return A[1] O(1);
Extract_Heap_maximum:swap(A[1],A[heap.size]) adjust up to down from A[1] to hold the max_heap character O(lgn) every stepfind max child
increase_Heap_max(i,key):[key>=A[i]],adjust down to up from A[i] toA[1] until satsify the max_heap O(lgn) every step find father
insert_heap_max:heap_size ++;A[heap.size]=key; increase_heap_max(heap.size,key) O(lgn) find father
//min_heap
heap_minimum:return A[1] O(1);
Extract_Heap_miniimum:swap ,adjust find min child; O(lgn)
decrease_heap_min:change value ,adjust up find smaller father O(lgn)
CLRS:max_heap and min_heap operation (pseudocode)的更多相关文章
- Find Median from Data Stream
常规方法 超时 class MedianFinder { vector<int> coll; public: MedianFinder(){ } void heapfu(vector< ...
- (转)【C++ STL】细数C++ STL 的那些事 -- priority_queue(优先队列)
装载自http://blog.csdn.net/tianshuai1111/article/details/7652553 一,概述 priority_queue是拥有权值观念的queue,它允许加入 ...
- STL序列式容器学习总结
STL序列式容器学习总结 参考资料:<STL源码剖析> 参考网址: Vector: http://www.cnblogs.com/zhonghuasong/p/5975979.html L ...
- 剑指offer算法题
数组中只出现一次的数字(一个整型数组里除了两个数字之外,其他的数字都出现了两次.请写程序找出这两个只出现一次的数字): 解法在于位运算中的异或,直接异或可以得到这两个数的异或,按照最后的有效数字位可以 ...
- STL中heap相关函数
heap并不是属于STL中的containers,而是在<algorithm>下提供了相关的函数 make_heap,sort_heap,pop_heap,push_heap 函数的说明: ...
- 中位数II
该题目与思路分析来自九章算法的文章,仅仅是自己做个笔记! 题目:数字是不断进入数组的,在每次添加一个新的数进入数组的同时返回当前新数组的中位数. 解答: 这道题是用堆解决的问题.用两个堆,max he ...
- 终端mysql Operation not permitted错误解决方案
前言 前段时间装mysql,就遇到了ln: /usr/bin/mysql: Operation not permitted的错误,网上好多方法都过时了,下边是我的解决方法 原因 这是因为苹果在OS X ...
- SVN:Previous operation has not finished; run 'cleanup' if it was interrupted
异常处理汇总-开发工具 http://www.cnblogs.com/dunitian/p/4522988.html cleanup failed to process the following ...
- Mysql Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='
MySQL字符串比较bug: select * from table_a a left join table_b b on a.field_a = b.field_b error: Illegal ...
随机推荐
- java处理日期时间
java.util.Calendar Calendar 类是一个抽象类,它为特定瞬间与一组诸如 YEAR.MONTH.DAY_OF_MONTH.HOUR 等 日历字段之间的转换提供了一些方法,并为操作 ...
- (C#) Parse xml 时, 返回的node值总是null。
网上查了一下,原因在于要parse的Xml文件本身包含了一些namespace,这些需要被添加进去. http://msdn.microsoft.com/zh-cn/library/system.xm ...
- Oracle远程数据库一直连接不上的原因:多了个空格
- hdu 1536 S-Nim(sg函数模板)
转载自:http://blog.csdn.net/sr_19930829/article/details/23446173 解题思路: 这个题折腾了两三天,参考了两个模板,在这之间折腾过来折腾过去,终 ...
- Python 图形 GUI 库 pyqtgraph
原文 Python 图形 GUI 库 pyqtgraph pyqtgraph 是纯 Python 图形 GUI 库,基于PyQT4 /pyside和NumPy.它主要目的用于在数学/科学/工程中.M ...
- Restful风格的简单实现办法
如果实在着急上Restful的URL在项目里 , 可以使用turkey的urlrewrite. 先在web.xml中加入如下代码 <!-- URL ReWrite --> <filt ...
- JAVA 数组排序
一.数组升序排序 实例: import java.util.Arrays; //导入数组处理 public class Test{ public static void main(String[] a ...
- 如何给ubuntu虚拟机添加硬盘和快捷键(转载)
From:http://os.51cto.com/art/201003/188721.htm 刚开始建立Ubuntu虚拟机时间,把容量设置为8Gb 了,然后没过几天就没有地方了,郁闷!查了一下,有几种 ...
- 在Virtual Box虚拟机中安装MS DOS!
原文地址:https://mylinuxramblings.wordpress.com/2010/12/05/linux-mint-debian-edition-lmde-first-impressi ...
- Valid Number @python
Valid Number Validate if a given string is numeric. Some examples:"0" => true" 0.1 ...