MCPcopy Create free account
hub / github.com/ua-nick/Data-Structures-and-Algorithms / CombSort

Function CombSort

CombSort/CombSort.go:3–22  ·  view source on GitHub ↗
(array []int)

Source from the content-addressed store, hash-verified

1package CombSort
2
3func CombSort(array []int) {
4 gapValue := len(array)
5 swapCount := 1
6 for gapValue >= 1 && swapCount != 0 {
7 if gapValue != 1 {
8 gapValue = int(float64(gapValue) / float64(1.3))
9 }
10 swapCount = 0
11 firstItem := 0
12 secondItem := gapValue
13 for secondItem != len(array) {
14 if array[firstItem] > array[secondItem] {
15 array[firstItem], array[secondItem] = array[secondItem], array[firstItem]
16 swapCount += 1
17 }
18 firstItem += 1
19 secondItem += 1
20 }
21 }
22}

Callers 1

TestCombSortFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestCombSortFunction · 0.68