forked from heqin-zhu/algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshellSort.py
More file actions
24 lines (23 loc) · 676 Bytes
/
shellSort.py
File metadata and controls
24 lines (23 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
''' mbinary
#########################################################################
# File : shellSort.py
# Author: mbinary
# Mail: [email protected]
# Blog: https://mbinary.xyz
# Github: https://github.com/mbinary
# Created Time: 2018-07-06 16:30
# Description:
#########################################################################
'''
def shellSort(s,inc=None):
if inc is None:inc = [1,3,5,7,11,13,17,19]
num = len(s)
inc.sort(reverse=True)
for i in inc:
for j in range(i,num):
cur = j
while cur>=i and s[j] > s[cur-i]:
s[cur] = s[cur-i]
cur-=i
s[cur] = s[j]
return s