mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-30 22:23:42 +00:00
Enhance shell sort syntax (#2035)
This commit is contained in:
parent
0e619065e7
commit
4768735668
|
@ -30,16 +30,11 @@ def shell_sort(collection):
|
|||
gaps = [701, 301, 132, 57, 23, 10, 4, 1]
|
||||
|
||||
for gap in gaps:
|
||||
i = gap
|
||||
while i < len(collection):
|
||||
temp = collection[i]
|
||||
for i in range(gap, len(collection)):
|
||||
j = i
|
||||
while j >= gap and collection[j - gap] > temp:
|
||||
collection[j] = collection[j - gap]
|
||||
while j >= gap and collection[j] < collection[j - gap]:
|
||||
collection[j], collection[j - gap] = collection[j - gap], collection[j]
|
||||
j -= gap
|
||||
collection[j] = temp
|
||||
i += 1
|
||||
|
||||
return collection
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user