惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
N
News and Events Feed by Topic
P
Privacy International News Feed
The Hacker News
The Hacker News
Schneier on Security
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
Security Latest
Security Latest
L
LINUX DO - 最新话题
阮一峰的网络日志
阮一峰的网络日志
Cisco Talos Blog
Cisco Talos Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
The Cloudflare Blog
博客园 - 【当耐特】
博客园 - Franky
P
Privacy & Cybersecurity Law Blog
Attack and Defense Labs
Attack and Defense Labs
云风的 BLOG
云风的 BLOG
月光博客
月光博客
D
Docker
Webroot Blog
Webroot Blog
The GitHub Blog
The GitHub Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
W
WeLiveSecurity
S
Security Affairs
Martin Fowler
Martin Fowler
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Security Archives - TechRepublic
Security Archives - TechRepublic
Microsoft Azure Blog
Microsoft Azure Blog
C
CERT Recently Published Vulnerability Notes
B
Blog
L
Lohrmann on Cybersecurity
T
Threatpost
量子位
S
Schneier on Security
V
Visual Studio Blog
S
Securelist
T
The Exploit Database - CXSecurity.com
Scott Helme
Scott Helme
V
Vulnerabilities – Threatpost
aimingoo的专栏
aimingoo的专栏
The Register - Security
The Register - Security
I
Intezer
Stack Overflow Blog
Stack Overflow Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
博客园 - 聂微东
小众软件
小众软件
罗磊的独立博客
雷峰网
雷峰网
Recorded Future
Recorded Future

博客园 - 小强小工

DataGrid设置中文列名 WinForm窗体生命周期 Oracle格式化函数 ORACLE时间间隔函数 浅谈数据库设计技巧(转) Oracle与SQLServer返回datatable列名大小写 oracle、sqlserver数据库排序空值null问题解决办法 MS SQL Server中的CONVERT日期格式化大全 .NET开发资源站点和.NET开源项目收集 C#中ToString格式大全 - 小强小工 - 博客园 oracle 事务 相关 Oracle SGA .NET中三种数据类型转换的区别:(type), type.Parse, Convert类 从追MM谈Java的23种设计模式 WinCE概念扫盲 将WinCE5.0模拟器连接到VS2005 .net的事件与委托(转载) VB有关handles 的问题 VB中的handles在C#中怎么写?
各种排序方法的综合比较
小强小工 · 2008-09-23 · via 博客园 - 小强小工

一、时间性能

平均的时间性能来分,有三类排序方法:

时间复杂度为

O(nlogn)的方法有:快速排序、堆排序和归并排序,其中以快速排序为最好;

时间复杂度为

O(n2)的有:直接插入排序、起泡排序和简单选择排序,其中以直接插入为最好,特别是对那些对关键字近似有序的记录序列尤为如此;

时间复杂度为

O(n)的排序方法只有,基数排序

待排记录序列按关键字顺序有序时,直接插入排序和起泡排序能达到O(n)的时间复杂度;而对于快速排序而言,这是最不好的情况,此时的时间性能蜕化为O(n2),因此是应该尽量避免的情况。

简单选择排序、堆排序和归并排序的时间性能不随记录序列中关键字的分布而改变

二、空间性能

指的是排序过程中所需的辅助空间大小。

1. 所有的

简单排序方法(包括:直接插入、起泡和简单选择)和堆排序的空间复杂度O(1)

2.

快速排序为O(logn ),为栈所需的辅助空间;

3.

归并排序所需辅助空间最多,其空间复杂度O(n );

4.

链式基数排序需附设队列首尾指针,则空间复杂度O(rd )