Skip to content

Commit

Permalink
Merge pull request #171 from Kiritoabc/master
Browse files Browse the repository at this point in the history
fix: update shell sort code and fix some describe
  • Loading branch information
hunterhug authored Oct 8, 2023
2 parents 94dc08a + ddae517 commit 460e4e3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion algorithm/sort/shell_sort.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func ShellSort(list []int) {
if deal < list[j] {
// 一直往左边找,比待排序大的数都往后挪,腾空位给待排序插入
for ; j >= 0 && deal < list[j]; j -= step {
list[j+1] = list[j] // 某数后移,给待排序留空位
list[j+step] = list[j] // 某数后移,给待排序留空位(注意移动是以step为步长)
}
list[j+step] = deal // 结束了,待排序的数插入空位
}
Expand Down
2 changes: 1 addition & 1 deletion code/sort/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func ShellSort(list []int) {
if deal < list[j] {
// 一直往左边找,比待排序大的数都往后挪,腾空位给待排序插入
for ; j >= 0 && deal < list[j]; j -= step {
list[j+1] = list[j] // 某数后移,给待排序留空位
list[j+step] = list[j] // 某数后移,给待排序留空位(注意移动是以step为步长)
}
list[j+step] = deal // 结束了,待排序的数插入空位
}
Expand Down

0 comments on commit 460e4e3

Please sign in to comment.