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

Function insertionSortRuns

sort/timsort.go:36–45  ·  view source on GitHub ↗

insertionSortRuns runs insertion sort on all the data runs one by one.

(data []T, runSize int)

Source from the content-addressed store, hash-verified

34
35// insertionSortRuns runs insertion sort on all the data runs one by one.
36func insertionSortRuns[T constraints.Ordered](data []T, runSize int) {
37 for lower := 0; lower < len(data); lower += runSize {
38 upper := lower + runSize
39 if upper >= len(data) {
40 upper = len(data)
41 }
42
43 Insertion(data[lower:upper])
44 }
45}
46
47// mergeRuns merge sorts all the data runs into a single sorted data slice.
48func mergeRuns[T constraints.Ordered](data []T, runSize int) {

Callers 1

TimsortFunction · 0.85

Calls 1

InsertionFunction · 0.85

Tested by

no test coverage detected