//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. NeHe OpenGL教程 第四十三课:FreeType库

    转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...

  2. matlab R2016b 设置界面为英文

    对于matlab的使用,最好还是使用英文好.这样既能让你熟悉直接的英文解释,也能学习一下英语. 对于中文版的matlab,默认的Matlab安装是中文,所以这里存在安装matlab后设置语言的需要. ...

  3. c#(特殊集合)

    Stack集合(先进后出) Stack ss = new Stack();//初始化 ss.Push(1);//.Push()一个一个推进,赋值ss.Push(2);ss.Push(3);ss.Pus ...

  4. php命名空间学习

    在一个命名空间中,当 PHP 遇到一个非限定的类.函数或常量名称时,它使用不同的优先策略来解析该名称. 1.类名称总是解析到当前命名空间中的名称.因此在访问系统内部或不包含在命名空间中的类名称时,必须 ...

  5. C++ operator 知识点

    [转]C++隐式类型转换 operator T http://m.blog.csdn.net/blog/micx0124/12389973# 对于operator关健字用于运算符重载这我们都知道,其实 ...

  6. centos下安装MySQL5.7

    1.查找mysqlwhereis mysql 2.删除mysqlyum remove mysql mysql-server mysql-libs mysql-server;rm –rf /usr/li ...

  7. jQuery-ajax: 取消关注|关注

    ylbtech-jQuery-ajax: 取消关注|关注 1.A,jQuery-效果图返回顶部   1.B,jQuery-Source Code(源代码)返回顶部 <script src=&qu ...

  8. 并发编程之二:wait、notify、notifyAll的使用方法

    wait().notify().notifyAll()是三个定义在Object类里的方法,可以用来控制线程的状态. public final native void wait(long timeout ...

  9. Good Sentences

    Wine in, truth out One is never too old to learn What is done can not be undone Time tries all thing ...

  10. VMware虚拟机的CentOS无法上网的解决方法

    前言:由于Linux下很多软件安装必须网络环境下进行,因此,对于如何在VMware下进行上网,我折腾了至少三天,今天上午,也即五一劳动节,终于搜到一遍技术文章,经过自己实践,VMware下Linux的 ...