- 浏览: 1397485 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
sdgxxtc:
[quo[color=red]te][/color]
C#使用OleDb读取Excel,生成SQL语句 -
zcs302567601:
博主,你好,一直都有个问题没有搞明白,就是 2.x的版本是通过 ...
NGUI所见即所得之UIPanel -
一样的追寻:
感谢楼主!
有向强连通和网络流大讲堂——史无前例求解最大流(最小割)、最小费用最大流 -
cp1993518:
感谢!从你的博客里学到了很多
Unity日志工具——封装,跳转 -
cp1993518:
学习了~,话说现在的版本custom还真的变委托了
NGUI所见即所得之UIGrid & UITable
排序算法群星豪华大汇演
排序算法相对简单些,但是由于它的家族比较庞大——这也许是因为简单的缘故吧,网上整理排序算法实在太多了,什么经典排序算法,八大排序算法总结,精通八大排序算法等枚不胜举,当然这里也不例外,同样是整理,同样是学习的过程。
之前一些排序算法总是说不清楚(作者自己的感受),这倒不是因为太难,作者觉得是因为排序算法太繁复了(一些算法之间的区别不是很明显),那也没有他法,只有各个击破,认真理解每个排序的原理。经过一段时间的学习和整理,已经剧本一定的规模,故作一个总览,方便查阅。
当然,对于浩大的排序算法,这里只能列举部分,对其进行分别介绍,有的介绍相对简单,有的比较反复,日后有时间学习再详加论述,可能有些读者会觉得每个算法讲解时间复杂度(其实都尽力覆盖)和应用会相对少点(作者也是一直这么期待多点应用),但是作者觉得这些都是建立在对算法原理的充分理解的基础上的,换句话说,如果能充分理解算法的真谛,时间复杂度和空间复杂度那其实不是信手拈来的事吗,至于应用主要是要结合实际问题,就想人生的阅历一样只有在漫长时间的浸泡才会逐渐丰满起来,所以学习切勿本末倒置,孰能生巧(掌握基本的排序算法,混合排序算法(作者没有进行整理,作者认为只要充分掌握基本的原理,遇到实际问题自然就会想到的)就不在话下了才是学习真正在的过程,学习是要学习融会贯通的能力,当然这也需要积累的过程。
下面再附上维基百科的对Sort Algorithm的整理:
Comparison of algorithms
In this table, n is the number of records to be sorted. The columns "Average" and "Worst" give the time complexity in each case, under the assumption that the length of each key is constant, and that therefore all comparisons, swaps, and other needed operations can proceed in constant time. "Memory" denotes the amount of auxiliary storage needed beyond that used by the list itself, under the same assumption. These are all comparison sorts. The run time and the memory of algorithms could be measured using various notations like theta, omega, Big-O, small-o, etc. The memory and the run times below are applicable for all the 5 notations.
Quicksort | Depends | Partitioning | Quicksort is usually done in place with O(log(n)) stack space.[citation needed] Most implementations are unstable, as stable in-place partitioning is more complex. Naïve variants use an O(n) space array to store the partition.[citation needed] | ||||
Merge sort | Depends; worst case is | Yes | Merging | Highly parallelizable (up to O(log(n))) for processing large amounts of data. | |||
In-place Merge sort | Yes | Merging | Implemented in Standard Template Library (STL);[2]can be implemented as a stable sort based on stable in-place merging.[3] | ||||
Heapsort | No | Selection | |||||
Insertion sort | Yes | Insertion | O(n + d), where d is the number of inversions | ||||
Introsort | No | Partitioning & Selection | Used in SGI STL implementations | ||||
Selection sort | No | Selection | Stable with O(n) extra space, for example using lists.[4] Used to sort this table in Safari or other Webkit web browser.[5] | ||||
Timsort | Yes | Insertion & Merging | comparisons when the data is already sorted or reverse sorted. | ||||
Shell sort | or |
Depends on gap sequence; best known is | No | Insertion | |||
Bubble sort | Yes | Exchanging | Tiny code size | ||||
Binary tree sort | Yes | Insertion | When using a self-balancing binary search tree | ||||
Cycle sort | — | No | Insertion | In-place with theoretically optimal number of writes | |||
Library sort | — | Yes | Insertion | ||||
Patience sorting | — | — | No | Insertion & Selection | Finds all the longest increasing subsequences within O(n log n) | ||
Smoothsort | No | Selection | An adaptive sort - comparisons when the data is already sorted, and 0 swaps. | ||||
Strand sort | Yes | Selection | |||||
Tournament sort | — | Selection | |||||
Cocktail sort | Yes | Exchanging | |||||
Comb sort | No | Exchanging | Small code size | ||||
Gnome sort | Yes | Exchanging | Tiny code size | ||||
Bogosort | No | Luck | Randomly permute the array and check if sorted. | ||||
[6] | Yes |
Non-Comparison of algorithms
The following table describes integer sorting algorithms and other sorting algorithms that are not comparison sorts. As such, they are not limited by a lower bound. Complexities below are in terms of n, the number of items to be sorted, k, the size of each key, and d, the digit size used by the implementation. Many of them are based on the assumption that the key size is large enough that all entries have unique key values, and hence that n << 2k, where << means "much less than."
Pigeonhole sort | — | Yes | Yes | ||||
Bucket sort (uniform keys) | — | Yes | No | Assumes uniform distribution of elements from the domain in the array.[7] | |||
Bucket sort (integer keys) | — | Yes | Yes | r is the range of numbers to be sorted. If r = then Avg RT = [8] | |||
Counting sort | — | Yes | Yes | r is the range of numbers to be sorted. If r = then Avg RT = [7] | |||
LSD Radix Sort | — | Yes | No | [7][8] | |||
MSD Radix Sort | — | Yes | No | Stable version uses an external array of size n to hold all of the bins | |||
MSD Radix Sort | — | No | No | In-Place. k / d recursion levels, 2d for count array | |||
Spreadsort | — | No | No | Asymptotics are based on the assumption that n << 2k, but the algorithm does not require this. |
要是你有任何建议或批评和补充,希望您能留言指出,不胜感激,更多参考请移步互联网。
发表评论
-
完结篇
2016-11-27 11:53 4926如题,这篇是我在iteye.com的最后一篇博客,后面会陆续在 ... -
一次北京,又一次开始:走在行云流水间
2014-05-03 09:43 2900一次北京,又一次开始 ... -
毕业了,就不能再那么纯真了?
2014-03-31 02:01 4521毕业了,就不能再那 ... -
C# 调用Delegate.CreateDelegate方法出现“未处理ArgumentException”错误解决
2013-05-31 12:24 3478在C# 调用Delegate.Create ... -
“奇怪”的后续
2013-05-10 19:02 1637写这篇博客主 ... -
数组问题集结号
2012-12-06 22:01 0数组是最简单的数据结构,数组问题作为公司招聘的笔试和面试题目 ... -
算法问题分析笔记
2012-12-05 11:59 01.Crash Balloon Zhejiang Univer ... -
雙月神話 by D.S.Qiu
2012-11-29 13:52 1934雙月神話 by D.S.Qiu 一直都对 ... -
Java基础进阶整理
2012-11-26 09:59 2260Java学习笔记整理 ... -
Java学习笔记整理
2012-11-24 23:43 211Java学习笔记整理 本文档是我个人 ... -
《C++必知必会》学习笔记
2012-11-24 23:40 2572《C++必知必会》学 ... -
《C++必知必会》学习笔记
2012-11-24 23:34 1《C++必知必会》学习笔 ... -
C语言名题精选百则——排序
2012-11-04 23:29 128第5章排 序 问题5.1 二分插入法(BIN ... -
C语言名题精选百则——查找
2012-11-04 23:29 4033尊重他人的劳动,支持原创 本篇博文,D.S.Q ... -
基本技术——贪心法、分治法、动态规划三大神兵
2012-11-03 19:30 0基本技术——贪心法、分治法、动态规划三大神兵 -
写在前面的话
2012-11-03 18:47 2379写在前面的话 尊重他人的劳动,支持原创 最近 ... -
优先队列三大利器——二项堆、斐波那契堆、Pairing 堆
2012-11-03 13:12 35492优先队列三大利器——二项堆、斐波那契堆、Pairing ... -
优先队列三大利器——二项堆、斐波那契堆、Pairing 堆
2012-11-03 13:01 3优先队列三大利器——二项堆、斐波那契堆、Pairing 堆 ... -
分布排序(distribution sorts)算法大串讲
2012-10-29 15:33 4568分布排序(distribution sorts)算法大串讲 ... -
归并排序(merge sorts)算法大串讲
2012-10-29 10:04 8220归并排序(merge sorts)算法大串讲 ...
相关推荐
选择排序算法、冒泡排序算法和插入排序算法的时间复杂度为O(n2),写法简单,逻辑易懂,但算力性价比不高,不适用于数据量较大时使用。 合并排序算法和快速排序算法采用了采用分治法、递归的方法,将时间复杂度降为...
该程序包含7大排序算法: # sort.bubbleSort() #冒泡排序 # sort.shellSort() #希尔排序 # sort.insertionSort() #插入排序 # sort.Selectionsort1() #选择排序 # sort.heapSort() #堆排序 # sort.countSort() ...
js排序算法动态显示js排序算法动态显示js排序算法动态显示js排序算法动态显示js排序算法动态显示js排序算法动态显示js排序算法动态显示js排序算法动态显示js排序算法动态显示js排序算法动态显示js排序算法动态显示js...
常用排序算法总结常用排序算法总结常用排序算法总结常用排序算法总结常用排序算法总结常用排序算法总结常用排序算法总结常用排序算法总结常用排序算法总结常用排序算法总结
最快的排序算法 C语言最简单的排序算法冒泡排序并返回排序前索引序号,排序算法数据结构
八大排序算法总八大排序算法总八大排序算法总八大排序算法总结
排序算法归档排序算法归档排序算法归档排序算法归档排序算法归档排序算法归档排序算法归档排序算法归档排序算法归档排序算法归档排序算法归档排序算法归档排序算法归档排序算法归档
排序算法排序算法排序算法排序算法排序算法排序算法排序算法
进行排序,而外部排序是因排序的数据很大,一次不能容纳全部的排序 记录,在排序过程中需要访问外存。常见的内部排序算法有:插入排 序、希尔排序、选择排序、冒泡排序、归并排序、快速排序、堆排序、 基数排序等。...
希尔排序,冒泡排序、快速排序递归排序,快速排序非递归排序,快速排序改进算法
排序算法是一种基本并且常用的算法。由于实际工作中处理的数量巨大,所以排序算法 对算法本身的速度要求很高。 而一般我们所谓的算法的性能主要是指算法的复杂度,一般用O方法来表示。在后面我将 给出详细的说明...
Verilog/C++实现排序算法:Verilog/C++实现排序算法:冒泡排序、选择排序、并行全比较排序、串行全比较排序。
1、熟悉快速排序的串行算法 2、熟悉快速排序的并行算法 3、实现快速排序的并行算法 3.2 实验环境及软件 单台或联网的多台PC机,Linux操作系统,MPI系统。 3.3实验内容 1、快速排序的基本思想 2、单处理机上快速...
最快的排序算法 谁才是最强的排序算法:快速排序-归并排序-堆排序,排序算法数据结构
总结了八大排序算法的写法,并且比较了效率,供大家学习借鉴。
程序员可以参考的8大排序算法。1)插入排序(直接插入排序、希尔排序) 2)交换排序(冒泡排序、快速排序) 3)选择排序(直接选择排序、堆排序) 4)归并排序 5)分配排序(基数排序)
1) 对以下6种常用的内部排序算法进行比较:起泡排序,直接插入排序,简单选择排序,快速排序,希尔排序,堆排序。 2) 待排序记录的文件个数不小于1000( 其数据用伪随机数产生),至少用5组不同的输入数据作比较;比较...
随机产生10000个浮点数,保存到a.txt文件中,再读取到内存中并分别用简单选择排序、冒泡排序、快速排序、希尔排序、归并排序、堆排序算法进行排序,显示排序过的数列的第1、10、100、1000、10000的具体数字和每个...
算法设计与分析-排序算法性能分析大礼包 包括题目要求pdf,报告文档,c++源代码,pre ppt 选择排序 冒泡排序 插入排序 合并排序 快速排序算法原理及代码实现 不同排序算法时间效率的经验分析方法 验证理论分析与经验...
十种排序算法介绍十种排序算法介绍十种排序算法介绍