FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm/003A_ShellSort.py at master · lixinchn/algorithm · GitHub
lixinchn
algorithm
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm
/
003A_ShellSort.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
23 lines (19 loc) · 717 Bytes
Breadcrumbs
algorithm
/
003A_ShellSort.py
Copy path
File metadata and controls
23 lines (19 loc) · 717 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# http://blog.csdn.net/morewindows/article/details/6668714
class
ShellSort
():
def
__init__
(
self
):
self
.
data
=
[
10
,
14
,
73
,
25
,
23
,
13
,
27
,
94
,
33
,
39
,
25
,
59
,
94
,
65
,
82
,
45
]
def
do
(
self
):
data_len
=
len
(
self
.
data
)
gap
=
data_len
/
2
while
gap
>
0
:
for
i
in
range
(
gap
,
data_len
):
if
self
.
data
[
i
]
<
self
.
data
[
i
-
gap
]:
j
=
i
while
j
-
gap
>
0
and
self
.
data
[
j
]
<
self
.
data
[
j
-
gap
]:
self
.
data
[
j
],
self
.
data
[
j
-
gap
]
=
self
.
data
[
j
-
gap
],
self
.
data
[
j
]
j
-=
gap
gap
/=
2
if
__name__
==
'__main__'
:
ss
=
ShellSort
()
ss
.
do
()
print
ss
.
data
Back
|
FazBrowse Home
|
New Git URL