![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
文章平均质量分 63
延鹏飞飞飞飞
初级测试工程师
展开
-
插入排序
a = [5,2,4,6,1,3]for j in range(1,len(a)): key = a[j] i=j-1 while i>=0 and a[i]>key: a[i+1] = a[i] a[i] = key i-=1print(a)原创 2017-06-04 09:26:57 · 213 阅读 · 0 评论 -
归并排序
# coding=utf-8from imooc.dataStructure.two.RandomTestcase import *'''时间复杂度是O(nlogn)'''''' 测试算法的性能 '''def testSort(sortName, sortfunc, l, r): start = time.time() sortfunc(arr,l, r) en原创 2017-07-18 10:53:26 · 201 阅读 · 0 评论 -
希尔排序
# coding=utf-8from imooc.dataStructure.two.RandomTestcase import *'''shell排序是插入排序的优化,时间复杂度最差是O(n^2),最好和插入排序一样是O(n),平均是O(n^3/2)'''''' 测试算法的性能 '''def testSort(sortName, sortfunc, arr, n): star原创 2017-07-18 10:54:37 · 262 阅读 · 0 评论 -
快速排序
# coding=utf-8from imooc.dataStructure.two.RandomTestcase import *def quickSort(arr,n): __quickSort(arr,0,n-1)def __quickSort(arr,l,r): if l >= r: return p = __partition(arr,l原创 2017-07-18 14:37:35 · 328 阅读 · 0 评论