希尔排序

Posted 淡季的风

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了希尔排序相关的知识,希望对你有一定的参考价值。

1.python

 1 def shellsort(l):                         
 2     n = len(l)
 3     h=1
 4     while h<n/3:
 5         h=3*h+1
 6         while h>=1:
 7             for i in range(h,n):
 8                 j = i
 9                 temp = l[j]
10                 while j>=h and l[j-h]>temp:
11                 l[j]=l[j-h]
12                 j=j-h
13                 l[j] = temp
14                 print l
15             h=(h-1)/3       
16             

 

以上是关于希尔排序的主要内容,如果未能解决你的问题,请参考以下文章