Skip to content

Instantly share code, notes, and snippets.

@Xifeng2009
Created September 14, 2018 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xifeng2009/8b7f51fe9d64bbd30238e3b055ddc545 to your computer and use it in GitHub Desktop.
Save Xifeng2009/8b7f51fe9d64bbd30238e3b055ddc545 to your computer and use it in GitHub Desktop.
希尔排序
def shell(arr):
n=len(arr)
h=1
while h<n/3:
h=3*h+1
while h>=1:
for i in range(h,n):
j=i
while j>=h and arr[j]<arr[j-h]:
arr[j], arr[j-h] = arr[j-h], arr[j]
j-=h
h=h//3
print arr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment