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

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
Security Latest
Security Latest
P
Privacy International News Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AI
AI
Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
S
Secure Thoughts
PCI Perspectives
PCI Perspectives
Simon Willison's Weblog
Simon Willison's Weblog
D
DataBreaches.Net
GbyAI
GbyAI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
罗磊的独立博客
V
Visual Studio Blog
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
V
V2EX
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tenable Blog
T
Threat Research - Cisco Blogs
T
Troy Hunt's Blog
V2EX - 技术
V2EX - 技术
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
L
Lohrmann on Cybersecurity
F
Full Disclosure
H
Help Net Security
博客园 - Franky
Stack Overflow Blog
Stack Overflow Blog
N
Netflix TechBlog - Medium
Engineering at Meta
Engineering at Meta
A
Arctic Wolf
O
OpenAI News
S
Securelist

博客园 - 小强小工

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 )