
python数据结构和算法
用python实现各种数据结构和算法
hxpjava1
毕业于武汉理工大学计算机系,12年开发架构经验,擅长java,k8s
展开
-
堆排序python实现
''' Created on 2017-1-6 @author: admin ''' def buildHeap(source,parent): if left(parent)>=len(source): return elif right(parent)>=len(source): if source[parent]>source[left(pa原创 2017-01-06 16:56:17 · 559 阅读 · 0 评论 -
用python实现归并排序
''' Created on 2017-1-6 @author: admin ''' from builtins import range, int def mergeSort(source,start,end): if(start>=end): return middle=int((start+end)/2) mergeSort(source, st原创 2017-01-06 11:51:18 · 522 阅读 · 0 评论 -
冒泡排序python实现
''' Created on 2017-1-6 @author: admin ''' def bubbleSort(source): for i in reversed(range(len(source))): for j in reversed(range(len(source)-i,len(source))): if source[j]<so原创 2017-01-06 12:52:58 · 568 阅读 · 0 评论 -
python实现快速排序
''' Created on 2017-1-6 @author: admin ''' def quickSort(source,start,end): if start==end: return index=shuffle(source, start, end) if(index-1>start): quickSort(source, s原创 2017-01-06 13:51:50 · 454 阅读 · 0 评论 -
python实现插入排序
''' Created on 2017-1-6 @author: admin ''' def insertSort(source): for i in range(1,len(source)): for j in reversed(range(1,i+1)): if source[j]<source[j-1]: tm原创 2017-01-06 14:02:31 · 622 阅读 · 0 评论 -
选择排序python实现
''' Created on 2017-1-6 @author: admin ''' def selectSort(source): for i in range(len(source)): mins=source[i] index=i for j in range(i,len(source)): if(mins>s原创 2017-01-06 14:10:35 · 588 阅读 · 0 评论 -
python实现希尔排序
''' Created on 2017-1-6 @author: admin ''' def shellSort(source): gap=len(source) while gap//2!=0: insertSort(source,gap//2) gap=gap//2 def insertSort(source,gap): for i原创 2017-01-06 14:48:42 · 645 阅读 · 0 评论