//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)的更多相关文章

  1. Find Median from Data Stream

    常规方法 超时 class MedianFinder { vector<int> coll; public: MedianFinder(){ } void heapfu(vector< ...

  2. (转)【C++ STL】细数C++ STL 的那些事 -- priority_queue(优先队列)

    装载自http://blog.csdn.net/tianshuai1111/article/details/7652553 一,概述 priority_queue是拥有权值观念的queue,它允许加入 ...

  3. STL序列式容器学习总结

    STL序列式容器学习总结 参考资料:<STL源码剖析> 参考网址: Vector: http://www.cnblogs.com/zhonghuasong/p/5975979.html L ...

  4. 剑指offer算法题

    数组中只出现一次的数字(一个整型数组里除了两个数字之外,其他的数字都出现了两次.请写程序找出这两个只出现一次的数字): 解法在于位运算中的异或,直接异或可以得到这两个数的异或,按照最后的有效数字位可以 ...

  5. STL中heap相关函数

    heap并不是属于STL中的containers,而是在<algorithm>下提供了相关的函数 make_heap,sort_heap,pop_heap,push_heap 函数的说明: ...

  6. 中位数II

    该题目与思路分析来自九章算法的文章,仅仅是自己做个笔记! 题目:数字是不断进入数组的,在每次添加一个新的数进入数组的同时返回当前新数组的中位数. 解答: 这道题是用堆解决的问题.用两个堆,max he ...

  7. 终端mysql Operation not permitted错误解决方案

    前言 前段时间装mysql,就遇到了ln: /usr/bin/mysql: Operation not permitted的错误,网上好多方法都过时了,下边是我的解决方法 原因 这是因为苹果在OS X ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. EntityFramework ,ef 介绍

    EntityFramework之领域驱动设计实践 分层架构 在引入实例以前,我们有必要回顾,并进一步了解分层架构.“层”是一种体系结构模式[POSA1],也是被广大软件从业人员用得最为广泛而且最为灵活 ...

  2. (C#) What is the difference between "const" and "static readonly" ?

    const int a must be initialized initialization must be at compile time readonly int a can use defaul ...

  3. POJ 3368 Frequent values RMQ 训练指南 好题

    #include<cstdio> #include<cstring> ; const int inf=0x3f3f3f3f; inline int max(int x,int ...

  4. HttpClient和HttpURLConnection整合汇总对比

    性能 1.HttpUrlConnection直接支持GZIP压缩:HttpClient也支持,但要自己写代码处理. 2.HttpUrlConnection直接支持系统级连接池,即打开的连接不会直接关闭 ...

  5. 转--2014年最新810多套android源码2.46GB免费一次性打包下载

    转载自:http://www.eoeandroid.com/thread-497046-1-1.html 感谢该博客主人无私奉献~~ 下面的源码是从今年3月份开始不断整理源码区和其他网站上的安卓例子源 ...

  6. C++ 局部变量的析构

    http://blog.chinaunix.net/uid-52437-id-2108747.html 在一个函数内,申明一个局部类变量.则这个变量什么时候析构呢? 并不是在函数退出,释放栈空间时候析 ...

  7. Guava 12-数学运算

    范例 int logFloor = LongMath.log2(n, FLOOR); int mustNotOverflow = IntMath.checkedMultiply(x, y); long ...

  8. Java序列化,serializable

    Java 串行化技术可以使你将一个对象的状态写入一个Byte 流里,并且可以从其它地方把该Byte 流里的数据读出来,重新构造一个相同的对象.这种机制允许你将对象通过网络进行传播,并可以随时把对象持久 ...

  9. Spring 的 BeanPostProcessor接口实现

    今天学习了一下Spring的BeanPostProcessor接口,该接口作用是:如果我们需要在Spring容器完成Bean的实例化,配置和其他的初始化后添加一些自己的逻辑处理,我们就可以定义一个或者 ...

  10. wall 和panel有啥区别

    Panel指的是一个面板,用它来对一些控件进行分组,就像组合框控件,即Visual Studio里面用的Group Box Control:而在一些软件界面里面也可以表现为工具条,比如编辑工具条.文件 ...