Skip to content

Commit f05e245

Browse files
optimization shell sort (#32)
1 parent d957853 commit f05e245

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sorts/shell_sort.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def shell_sort(array):
2828
while j >= 0 and insert_value < array[j]:
2929
array[j + gap] = array[j]
3030
j -= gap
31-
array[j + gap] = insert_value
31+
if j != i - gap:
32+
array[j + gap] = insert_value
3233
gap >>= 1
3334
return array
3435

0 commit comments

Comments
 (0)