Internal Sort:

Bubble      O(n2)

Selection     O(n2)

Insertion    O(n2)

Shell      O(nlogn)

Merge      O(nlogn)

Heap      O(nlogn)

Quick Sort    O(nlogn)

Tree Sort(BST)  O(nlogn)

Linear Sorting:

Counting Sort    O(n)

BUcket Sort    O(n)

Radix Sort    O(n)

External Sorting:

K chunks of data need to be sorted and a K-way merge has to be completed.     Assembly Line

Problems:

pro22: Nearly Sorted.  Given a array of n elements, each which is at most K positions from its target position, devise an algorithm that sort in O(nlogK).

Insert the first K elements into a binary heap of size K. Insert the next element from the array into the heap, and delete the minimum element from the heap.\

pro35: Nuts and Bolts. We are given a box which contains bolts and nuts. Assume that there are n nuts and n bolts and that each nut matches exactly one bolt. By trying to match a bolt and a nuts we can see which one is bigger, but we cannot compare two bolts or two nuts directly.

We can use divide-and-conquer to solve. Pick a random bolt B[i], Using this bolt to rearrange the array of nuts into three groups of elements:

  •   Nuts smaller than B[i]
  •   Nuts matches B[i]
  •   Nuts larger than B[i]

Chpater 10: Sorting的更多相关文章

  1. SQL Server2012 T-SQL基础教程--读书笔记(8 - 10章)

    SQL Server2012 T-SQL基础教程--读书笔记(8 - 10章) 示例数据库:点我 CHAPTER 08 数据修改 8.1 插入数据 8.1.1 INSERT VALUES 语句 8.1 ...

  2. 《算法4》2.1 - 选择排序算法(Selection Sort), Python实现

    选择排序算法(Selection Sort)是排序算法的一种初级算法.虽然比较简单,但是基础,理解了有助于后面学习更高深算法,勿以勿小而不为. 排序算法的语言描述: 给定一组物体,根据他们的某种可量化 ...

  3. 《算法4》2.1 - 插入排序算法(Insertion Sort), Python实现

    排序算法列表电梯: 选择排序算法:详见 Selection Sort 插入排序算法(Insertion Sort):非常适用于小数组和部分排序好的数组,是应用比较多的算法.详见本文 插入排序算法的语言 ...

  4. 11、ABPZero系列教程之拼多多卖家工具 拼团提醒功能页面实现

    上一篇讲解了拼团提醒逻辑功能实现,现在继续实现页面功能. Core项目 打开AbpZeroTemplate-zh-CN.xml语言文件,在末尾添加如下代码: 文件路径:D:\abp version\a ...

  5. dataTable之自定义按钮实现全表 复制 打印 导出 重载

    //本文对常用表格插件datatable 的自定义按钮功能键进行详细解释//其中 15-78行是定义表单//16 18 19 三行定义自定义功能按钮 实现对全表的 复制 打印 导出(csv即excel ...

  6. [转]Sorting, Filtering, and Paging with the Entity Framework in an ASP.NET MVC Application (3 of 10)

    本文转自:http://www.asp.net/mvc/overview/older-versions/getting-started-with-ef-5-using-mvc-4/sorting-fi ...

  7. [转]10个有关RESTful API良好设计的最佳实践

    Web API已经在最近几年变成重要的话题,一个干净的API设计对于后端系统是非常重要的. 通常我们为Web API使用RESTful设计,REST概念分离了API结构和逻辑资源,通过Http方法GE ...

  8. 10分钟学习pandas

    10 Minutes to pandas This is a short introduction to pandas, geared mainly for new users. You can se ...

  9. WebGrid with filtering, paging and sorting 【转】

    WebGrid with filtering, paging and sorting by Jose M. Aguilar on April 24, 2012 in Web Development A ...

随机推荐

  1. C++中extern “C”含义深层探索

    C++中extern “C”含义深层探索 extern “C” 是一个双向都需要用到的语法表示,就是说在cpp引用c头文件,或者c引用cpp文件时都需要用到.但extern “C” 永远只能在cpp引 ...

  2. iOS Foundation框架简介 -1.常用结构体的用法和输出

    1.安装Xcode工具后会自带开发中常用的框架,存放的地址路径是: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.plat ...

  3. centos6.5安装fpm打包工具

    FPM功能简单说就是将一种类型的包转换成另一种类型.FPM的github:https://github.com/jordansissel/fpm 1.支持的源类型包: dir: 将目录打包成所需要的类 ...

  4. NSS_04 extjs中grid接收datetime类型参数列

    今天在做用户列表时发现, asp.net mvc3的控制器在返回JsonResult结果时, 会把对象内的DateTime类型成员,解析为类似于\/Date(1238606590509)\/的格式 , ...

  5. silverlight 文本框只能输入数字

    void mobile_KeyUp(object sender, KeyEventArgs e) { Regex rg = new Regex("^[0-9]{1,11}$"); ...

  6. 一款jquery编写图文下拉二级导航菜单特效

    一款jquery编写图文下拉二级导航菜单特效,效果非常简洁大气,很不错的一款jquery导航菜单特效. 这款jquery特效适用于很多的个人和门户网站. 适用浏览器:IE8.360.FireFox.C ...

  7. HTML:form表单总结,input,select,option,textarea,label

    <form>标签是块级元素. form标签的标准属性有id,class,style,title,lang,xml:lang. 表单能够包含input元素(包含button,checkbox ...

  8. Elastix 禁用SSL(https),还原为 http 访问

    1.相关配置文件目录: Apache的配置文件:httpd.conf,位于:/etc/httpd/conf/httpd.conf,配置文件中包含 Include conf.d/*.conf ,引入了  ...

  9. 在 SQL Server 中的网络数据库文件的支持说明

    其实就是一个学员问SQL Server 是否能存放的于NAS(UAC 的路径下). 官方的回答简略版本为:可以,需要满足一些强制性的硬件要求.但需要考虑一系列的性能的问题. http://suppor ...

  10. django 更新model

    修改models.py 中对应的class 在admin.py 中 增加 admin.site.register(WafDevice) 进入dbshell python manage.py dbshe ...