Optimization shell sort (#4119)

* optimization

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
杜远超 2021-02-26 09:01:50 +08:00 committed by GitHub
parent 71b1202d04
commit 67b33a295b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,7 +26,8 @@ def shell_sort(collection):
while j >= gap and collection[j - gap] > insert_value:
collection[j] = collection[j - gap]
j -= gap
collection[j] = insert_value
if j != i:
collection[j] = insert_value
return collection