Chpater 10: Sorting
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的更多相关文章
- SQL Server2012 T-SQL基础教程--读书笔记(8 - 10章)
SQL Server2012 T-SQL基础教程--读书笔记(8 - 10章) 示例数据库:点我 CHAPTER 08 数据修改 8.1 插入数据 8.1.1 INSERT VALUES 语句 8.1 ...
- 《算法4》2.1 - 选择排序算法(Selection Sort), Python实现
选择排序算法(Selection Sort)是排序算法的一种初级算法.虽然比较简单,但是基础,理解了有助于后面学习更高深算法,勿以勿小而不为. 排序算法的语言描述: 给定一组物体,根据他们的某种可量化 ...
- 《算法4》2.1 - 插入排序算法(Insertion Sort), Python实现
排序算法列表电梯: 选择排序算法:详见 Selection Sort 插入排序算法(Insertion Sort):非常适用于小数组和部分排序好的数组,是应用比较多的算法.详见本文 插入排序算法的语言 ...
- 11、ABPZero系列教程之拼多多卖家工具 拼团提醒功能页面实现
上一篇讲解了拼团提醒逻辑功能实现,现在继续实现页面功能. Core项目 打开AbpZeroTemplate-zh-CN.xml语言文件,在末尾添加如下代码: 文件路径:D:\abp version\a ...
- dataTable之自定义按钮实现全表 复制 打印 导出 重载
//本文对常用表格插件datatable 的自定义按钮功能键进行详细解释//其中 15-78行是定义表单//16 18 19 三行定义自定义功能按钮 实现对全表的 复制 打印 导出(csv即excel ...
- [转]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 ...
- [转]10个有关RESTful API良好设计的最佳实践
Web API已经在最近几年变成重要的话题,一个干净的API设计对于后端系统是非常重要的. 通常我们为Web API使用RESTful设计,REST概念分离了API结构和逻辑资源,通过Http方法GE ...
- 10分钟学习pandas
10 Minutes to pandas This is a short introduction to pandas, geared mainly for new users. You can se ...
- WebGrid with filtering, paging and sorting 【转】
WebGrid with filtering, paging and sorting by Jose M. Aguilar on April 24, 2012 in Web Development A ...
随机推荐
- jQuery 手风琴侧边菜单
动手做了一个简单手风琴菜单,上图: 点击 B 可收缩 C 列表,点击 C 改变自身和父节点 B 的样式,悬浮时均有不同的样式改变. 先看页面代码,列表的嵌套: <div id="men ...
- 抽象类(abstract)是否可以继承自实体类 ?
可以. 但是这个实体类必须有无参构造函数(默认的构造函数). 如: public class A { //这个构造函数必须要有(在没有构造函数重载时可以省略,因为运行时会为A添加默认构造函数) pub ...
- java基础学习01
学习主意:边看视频,边编写代码,学习成果体现在代码
- NFS参数配置详细说明
摘抄自:http://www.linuxidc.com/Linux/2012-05/61527p3.htm 1.NFS概述 NFS:Network file system,网络文件系统: 由sun公司 ...
- [Apache] 2.2与2.4版本在设置虚拟域名时的小差别
Apache服务器配置虚拟步骤: 1.在httpd.conf中将附加配置文件httpd-vhosts.conf包含进来,接着在httpd-vhosts.conf中写入如下配置: #LoadModule ...
- HTML5-Video & Audio
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- 【Qt】Qt国际化(系统文本-QMessageBox按钮、QLineEdit右键菜单等)【转】
简介 使用Qt的时候,经常会遇到英文问题,例如:QMessageBox中的按钮.QLineEdit.QSpinBox.QScrollBar中的右键菜单等.通常情况下,我们软件都不会是纯英文的,那么如何 ...
- mybatis的一对多映射
延续mybatis的一对一问题,如果一个用户有多个作品怎么办?这就涉及到了一对多的问题.同样的,mybatis一对多依然可以分为两种方式来解决. 一.使用内嵌的ResultMap实现一对多映射 1)实 ...
- mysql删除、修改字段默认值
alter table表名alter column字段名drop default; (若本身存在默认值,则先删除) alter table 表名 alter column 字段名 set defaul ...
- 使用Telerik的登陆模板实现DoubanFm的登陆(WP7)
Telerik的控件很强大.我们直接使用其登陆模板. 在装过Telerik WP版后,就可以在VS里非常方便的添加页面了. 我们选择 Sign In Form 其XAML不是很长,直接贴出来 < ...