vlambda博客
学习文章列表

Python-希尔排序算法

def shell_sort(alist): n = len(alist) gap = n // 2 while gap > 0: for i in range(gap, n): j = i while j >= gap: if alist[j] < alist[j - gap]: alist[j], alist[j - gap] = alist[j - gap], alist[j] j -= gap else: break gap //= 2  if __name__ == "__main__":    list1 = [6162245011208] shell_sort(list1) print(list1)