mirror of
https://github.com/0xAX/go-algorithms
synced 2024-11-13 13:10:30 +00:00
15 lines
288 B
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]
|
|
}
|
|
}
|
|
}
|
|
}
|