希尔排序
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
赞赏
长按二维码向我转账
受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。
已发送
发送中
微信扫一扫关注该公众号