2
0
mirror of https://github.com/0xAX/go-algorithms synced 2024-11-16 00:12:53 +00:00
go-algorithms/sorting/shell_sort.go

15 lines
288 B
Go

package main
/*
* Shell sort - http://en.wikipedia.org/wiki/Shellsort
*/
func ShellSort(arr []int) {
for d := int(len(arr)/2); d > 0; d /= 2 {
for i := d; i < len(arr); i++ {
for j := i; j >= d && arr[j-d] > arr[j]; j -= d {
arr[j], arr[j-d] = arr[j-d], arr[j]
}
}
}
}