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. java大数--总结

    BigInteger(高精度整数) 1.所在包: java.math.BigInteger 2.大数运算,以下返回类型均为BigInteger BigInteger a; BigInteger b; ...

  2. defrag磁盘整理命令

    1: Microsoft 磁盘碎片整理程序 2: 版权所有 (c) 2007 Microsoft Corp. 3: 参数错误. (0x80070057) 4: 描述: 5: 定位并合并本地卷中的碎片文 ...

  3. n盏灯亮灭问题

    前几天看了华为的一个上机操作题,讲得是n盏灯亮灭问题,本质上还是数学问题,感觉很有趣,和大家分享一下,问题描述如下: 有n盏灯排成一排,依次标号1,2,…,n,每盏灯都有一根拉线开关,最初电灯都是关着 ...

  4. 3月3日 Mark

    感觉LeetCode OJ 水题较多... 不过回复基础就是这样吧.. 刚刚和Gaewah聊了下,后续可以考虑去做Topcoder的SRM或者codeforces,Mark.

  5. 【转】asp.net mvc3 简单缓存实现sql依赖

    asp.net mvc3 简单缓存实现sql依赖   议题 随 着网站的发展,大量用户访问流行内容和动态内容,这两个方面的因素会增加平均的载入时间,给Web服务器和数据库服务器造成大量的请求压力.而大 ...

  6. js生成 1-100 不重复随机数

    var count=100; var a=new Array(); for(var i=0;i<100;i++){ a[i]=i+1; } a.sort(function(){ return 0 ...

  7. memory model

    最近看C++11 atomic发现对memory_order很是不理解,memory_order_relaxed/memory_order_consume/memory_order_acquire/m ...

  8. CentOS学习笔记--基本命令--目录的相关操作

    Linux基本命令--目录的相关操作 常见的处理目录的命令吧: cd:变换目录 pwd:显示目前的目录 mkdir:创建一个新的目录 rmdir:删除一个空的目录 cd (变换目录) cd是Chang ...

  9. MySQL excel导入错误 Out of range value adjusted for column

    修改my.ini,将 sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"改为 sql ...

  10. Django模版进阶

    # -*- coding: utf-8 -*-from django.shortcuts import renderdef home(request): string = "测试" ...