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 ...
随机推荐
- Titan-红号楼宗谱案例
一. 简介 titan:存储,查询图形结构的数据库.分布式集群环境下,可支持数以千亿级别的点和边,同时支持上千个并发的实时的复杂图形遍历,支持ACID事务. 架构:支持以下3方面的自由组合 (1)节点 ...
- 关于c语言中qsort函数的一点心得
今天写c时无意间用到了排序,便想着使用c语言标准库中提供的排序函数,即qsort函数(c++stl中提供了sort函数用于排序),首先是介绍qsort函数的一些基本用法(以下内容转自: http:// ...
- Unable to locate Android SDK used by project
Unable to locate Android SDK used by project: DJIgojava.lang.RuntimeException: Unable to locate Andr ...
- c# 对话框交换数据
本例是一个管理联系人信息的小程序,程序有两个窗体,一个主窗体,在listview控件中显示联系人信息列表,一个对话框窗体,用来显示和修改 某个联系人的信息.通过主窗体的菜单命令,可以打开对话框,并把主 ...
- c# 贪吃蛇源码
using UnityEngine; using System.Collections;using System.Diagnostics;using UnityEngine.SceneManageme ...
- UCOS-信号标志组(学习笔记)
信号标志组即根据各任务的信号进行逻辑运算,根据逻辑运算的结果决定是否进行.发送方指定向那个标志组的哪一位(响应位等于1表明向哪一位发)发1还是0.等待逻辑结果的任务指定等待那个标志组的哪几位.这几位按 ...
- JAVA 构造代码块
class G{ G(){ System.out.println("我是无参构造方法"); } G(String name){ System.out.println("我 ...
- Cassandra安装及其简单试用
官方主页:http://cassandra.apache.org/ 简介: The Apache Cassandra Project develops a highly scalable second ...
- iOS获取电量方法
ios简单的方法: [UIDevice currentDevice].batteryMonitoringEnabled = YES; double deviceLevel = [UIDevice cu ...
- doc2vec 利用gensim 生成文档向量
利用gensim 直接生成文档向量 def gen_d2v_corpus(self, lines): with open("./data/ques2_result.txt", &q ...