MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / Shell

Function Shell

sort/shellsort.go:5–14  ·  view source on GitHub ↗
(arr []T)

Source from the content-addressed store, hash-verified

3import "github.com/TheAlgorithms/Go/constraints"
4
5func Shell[T constraints.Ordered](arr []T) []T {
6 for d := int(len(arr) / 2); d > 0; d /= 2 {
7 for i := d; i < len(arr); i++ {
8 for j := i; j >= d && arr[j-d] > arr[j]; j -= d {
9 arr[j], arr[j-d] = arr[j-d], arr[j]
10 }
11 }
12 }
13 return arr
14}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected