摘要:
本文介绍的排序算法有:冒泡排序,选择排序,插入排序,归并排序,希尔排序,堆排序,快速排序,计数排序,基数排序,桶排序。包括定义描述、排序过程、复杂度和代码实现(如有错误,请指正 Thanks)。概念:排序稳定:如果两个数相同,对他们进行的排序结果为他们的相对顺序不变。原地排序:原地排序就是指不申请多余的空间来进行的排序,就是在原来的排序数据中比较和交换的排序。例如快速排序,堆排序等都是原地排序,合并排序,计数排序等不是原地排序。冒泡排序 [Bubble Sort] 依次比较相邻的两个数,将小数放在前面,大数放在后面。 复杂度: 最差时间复杂度[O(n^2)],最优时间复杂度[O(n)],... 阅读全文