希尔排序

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             

 

posted @ 2017-06-24 00:10  淡季的风  阅读(118)  评论(0)    收藏  举报