Skip to content

Commit 67b33a2

Browse files
realDuYuanChaogithub-actions
and
github-actions
authored
Optimization shell sort (#4119)
* optimization * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
1 parent 71b1202 commit 67b33a2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sorts/shell_sort.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def shell_sort(collection):
2626
while j >= gap and collection[j - gap] > insert_value:
2727
collection[j] = collection[j - gap]
2828
j -= gap
29-
collection[j] = insert_value
29+
if j != i:
30+
collection[j] = insert_value
3031
return collection
3132

3233

0 commit comments

Comments
 (0)