当前位置:网站首页>关于常见排序的稳定性
关于常见排序的稳定性
2022-07-22 22:35:00 【Harris-H】
关于常见排序的稳定性
1.冒泡排序
显然对于两个相邻且相同的元素,不会交换相对位置,因此是稳定的。
2.插入排序
插排也是基于相邻元素交换,所以也是稳定的。
3.选择排序

可能存在选择第 i i i小的元素时,把原本相同的元素的相对位置破坏了。
4.归并排序
合并时,不改变相对顺序,因为是左边+右边拼接。
5.快速排序
选择的基数的不同,可能会导致排序结果不同,相同元素的相对性被破坏。
6.堆排序
堆排序不稳定,因为堆上的操作可以更改相等项目的相对顺序。
7.希尔排序
本质就是分组插入排序,组内相对顺序不变,组间相对顺序可能变化了,所以不稳定。
8.基数排序
稳定的,最开始会将下标作为第二关键字。
9.桶排序
稳定的,同基数排序一样。
10.计数排序
稳定的,开了辅助数组记录每个数出现的次数,计数排序不是基于元素比较,而是利用数组下标来确定元素的正确位置。
边栏推荐
- Understand the interrupt system in STM32 in simple terms -- from principle to simple engineering examples -- nanny level tutorial
- H7-TOOL串口脱机烧录操作说明,支持TTL串口,RS232和RS485(2022-06-30)
- C语言函数(1)
- 原生js实现dom的获取及操作
- 学习总结 | 真实记录 MindSpore 两日集训营能带给你什么(一)!
- VMware virtual machine changes static IP and reports an error unit network Service entered failed state solution
- js 正则删除span标签以及标签里面的内容
- Matlab保存数据到csv文件的方法分享
- Come on, slide to the next little sister
- Jmeter查看结果树之查看响应的13种详解方法!
猜你喜欢

Can the formatted data of the USB flash disk be recovered? How to recover the formatted data of the USB flash disk

Spark疑难杂症排查-Premature EOF: no length prefix available

树以及二叉树的常用性质以及遍历

Networkx visualizes graphs

轮毂电机主动减振系统及其垂向性能优化

如何用C语言实现简单职工信息管理系统

来,滑动到下一个小姐姐

Cloud computing may become a new inflection point in the era? From which point can we see?

二冲程发动机均值模型仿真

Three things programmers want to do most | comics
随机推荐
开发者分享|MindSpore Lite 体验,一键实现图像分割
学习总结 | 真实记录 MindSpore 两日集训营能带给你什么(一)!
Understand the interrupt system in STM32 in simple terms -- from principle to simple engineering examples -- nanny level tutorial
Web resource sharing
学会这些Sketchup技巧,工作效率提高一半
Web资源共享
Google Earth engine app - a complete map legend app (land use classification of western United States)
Expérience II Yuv
RPC-BDY(5)-服务自动注销、负载均衡
算法面试高频题解指南【一】
轮毂电机主动减振系统及其垂向性能优化
Spark troubleshooting -precondition eof: no length prefix available
组蛋白研究丨Worthington小牛胸腺组蛋白的特征及文献参考
1.11 ArrayList & student management system
C language minesweeping
大咖訪談 | 開源社區裏各種奇怪的現狀——夜天之書陳梓立tison
C语言函数(1)
1.10 API and string
改变this指向了解一下
Solution to the second game of 2022 Hangzhou Electric Multi school league