码迷,mamicode.com
首页 > 编程语言 > 详细

希尔排序

时间:2017-06-24 00:52:44      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:for   排序   pre   and   div   log   int   shel   logs   

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             

 

希尔排序

标签:for   排序   pre   and   div   log   int   shel   logs   

原文地址:http://www.cnblogs.com/lowseasonwind/p/7072060.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!