diptangsu / Sorting-Algorithms

Types of function parameters can be combined CRT-A0017
Style
Major
3 years ago4 years old
func(a []int, b []int) []int could be replaced with func(a, b []int) []int
 2
 3import "fmt"
 4
 5func merge(a []int, b []int) []int { 6
 7  var r = make([]int, len(a) + len(b))
 8  var i = 0
func(arr []int, x int, y int, dir int) could be replaced with func(arr []int, x, y, dir int)
 2
 3import "fmt"
 4
 5func compAndSwap(arr []int, x int, y int, dir int) { 6	if((dir==1 && arr[x]>arr[y]) || (dir==0 && arr[x]<arr[y])) {
 7		arr[x], arr[y] = arr[y], arr[x]
 8	}
func(arr []int, low int, count int, dir int) could be replaced with func(arr []int, low, count, dir int)
 8	}
 9}
10
11func bitonicMerge(arr []int, low int, count int, dir int) {12	if(count > 1) {
13		k := count/2
14		for i:=low; i<low+k; i++ {
func(arr []int, low int, count int, dir int) could be replaced with func(arr []int, low, count, dir int)
20	}
21}
22
23func bitonicSort(arr []int, low int, count int, dir int) {24	if(count > 1) {
25		k := count/2
26		bitonicSort(arr, low, k, 1)
func(arr []int, n int, dir int) could be replaced with func(arr []int, n, dir int)
30	}
31}
32
33func sort(arr []int, n int, dir int) {34	bitonicSort(arr, 0, n, dir)
35}
36