算法
Zhang__Yue
这个作者很懒,什么都没留下…
展开
-
排序算法之 希尔排序算法(Shell Sort):(Python)
Wikipedia 希尔排序: 代码: # Shell_Sort def shell_sort(lst): length = len(lst) gap = length/2 while gap: for i in xrange(gap): for j i原创 2016-11-03 18:24:50 · 345 阅读 · 0 评论 -
排序算法之 简单选择排序算法(Simple Selection Sort):(Python)
简单选择排序算法 描述 见Wikipedia :简单选择排序算法 代码: # Simple_Selection_Sort def simple_selection_sort(lst): length = len(lst) for i in xrange(length-1): flag = i for j in xrange(i+1,length)原创 2016-11-03 18:42:56 · 391 阅读 · 0 评论 -
排序算法之 堆排序算法(Heap Sort):(Python)
此算法代码尚有点问题,容后再看: Wikipedia :点击打开链接 # Straight Insertion Sort def heap_sort(lst): length = len(lst) for i in xrange(0, len(lst)): index = 0 lst.insert(index,lst[i]) de原创 2016-11-05 17:26:01 · 470 阅读 · 0 评论 -
排序算法之 冒泡排序算法(Bubble Sort):(Python)
Wikipedia:冒泡排序 代码: def bubble_sort(lst): Pos = 1 while (Pos > 0): Pos = 0 for i in xrange(len(lst)-1): if lst[i]>lst[i+1]: lst[i],lst[i+1]=lst[i+1原创 2016-11-05 21:22:49 · 521 阅读 · 0 评论 -
排序算法之 直接插入排序算法(Straight Insertion Sort):(Python)
代码:# Straight Insertion Sortdef straight_insertion_sort(lst): length = len(lst) for i in xrange(length): if i == 0: continue k=i for j in xrange(i):原创 2016-11-03 15:01:52 · 423 阅读 · 0 评论