Life

Wednesday, September 5, 2018

排序算法

常用排序算法归纳
评价排序算法好坏的标准:
1.执行时间和所需的辅助空间。
2.算法本身的复杂程度。

排序稳定性时间复杂度空间复杂度
气泡排序(bubble sort)稳定最差、平均为O(n²),最好为O(n)1
插入排序(insertion sort)稳定最差、平均为O(n²),最好为O(n)1
归并排序(merge sort)稳定最差、平均和最好都是O(nlog n)O(n)
二叉树排序(Binary tree sort)稳定O(nlog n)O(n)
选择排序(selection sort)不稳定最差、平均都是O(n²)1
堆排序(heapsort)不稳定最差、平均和最好都是O(nlog n)1
快速排序(quicksort)不稳定平均是O(n log n),最坏情况O(n²)O(log n)
版权声明
本博客所有的原创文章,作者皆保留版权。转载必须包含本声明,保持本文完整,并以超链接形式注明作者Leslie Tien和本文原始地址:
https://leslietien.blogspot.com/2018/12/blog-post.html

No comments:

Post a Comment