摘要:
import random def bucket_sort(li, n=100, max_num=10000): buckets = [[] for _ in range(n)] # 创建桶 for var in li: i = min(var // (max_num // n), n-1) # i 阅读全文
摘要:
计数排序 import random def count_sort(li, count=100): count = [0 for _ in range(count+1)] for val in li: count.append(val) li.clear() for ind, val in enum 阅读全文
摘要:
希尔排序 def insert_sort_gap(li, gap): for i in range(gap, len(li)): #i 表示摸到的牌的下标 tmp = li[i] j = i - gap #j指的是手里的牌的下标 while j >= 0 and li[j] > tmp: li[j+ 阅读全文