摘要:
冒泡排序的思想: 将元素两两之间进行比较,谁大就往后移动,直到将最大的元素排到最后面,一直循环,就形成了有序的序列 # 冒泡排序 def bubble(arr): length = len(arr) for i in range(length-1): for j in range(length-1- 阅读全文
摘要:
希尔排序是不稳定排序的算法,希尔排序是在插入的排序上面进行了优化。 def shell_sort(a): step = len(a)//2 while step >= 1: for i in range(step, len(a)): while i - step >= 0 and a[i] < a[ 阅读全文