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 ...
随机推荐
- SpringMVC4.0.3 @ResponseBody JSON 中文乱码问题
@RequestMapping(value="listUserJson.html",produces="text/html;charset=UTF-8") @R ...
- vim 学习日志(1):剪切,复制,粘贴,删除,撤销
一:光标命令 左h 上j 下k 右l :goto n 表示跳转到文本的第n个字符 :n 表示跳到第n行 nG n为行数,该命令立即使光标跳到指定行:n为空,光标跳到文件最后一行. Ctrl+G ...
- (Delphi) Windows 32 API程序设计目录
这里所有程序均使用Delphi调用Windows 32 API方式实现,并不是使用VCL已经封装好的类实现的! (一)第一个窗口程序 01 创建第一个窗口.
- Win7允许被ping
我们可以通过命令行方式来执行入站 Ping 的规则是启用还是禁用,命令行如下: netsh firewall set icmpsetting 8 netsh firewall set icmpsett ...
- java基础-排序
冒泡排序 选择排序 生成数组,数组元素值为1-1000
- CRM报表打印
删除路径下的文件 C:\Windows\Downloaded Program Files\rsclientprint.dll路径下的这个dll文件,重新登录crm选择一个面单点击打印按钮重新安装插件
- selenium启动firefox、ie、chrome各浏览器方法
1.启动firefox浏览器 a.如果你的本地firefox是默认路径安装的话,如下方式即可启动浏览器 WebDriver driver = new FirefoxDriver(); driver.g ...
- TFS 2010 配置的时候,提示TF255466错误
TFS 2010 配置的时候,提示TF255466错误 Error [ System Checks ] TF255466: The configuration process for Team Fou ...
- ArcGIS上根据经纬度求地球表面两点间距离的实现
ArcGIS上根据经纬度求地球表面两点间距离的实现 以米为单位..Net2.0,C#实现. public static double DistanceOfTwoPoints(double ...
- Java是传值还是传引用
http://www.bccn.net/Article/kfyy/java/jszl/200601/3069.html 对于基本数据类型(整型.浮点型.字符型.布尔型等),传值;对于引用类型(对象.数 ...