bucket_sort_test

  • 2022-12-14
  • 浏览 (470)

bucket_sort_test.go 源码

package sort

import (
	"fmt"
	"math/rand"
	"sort"
	"testing"
	"time"
)

func TestBucketSort(t *testing.T) {
	var data []int
	rand.Seed(time.Now().UnixNano())

	for i := 0; i < 104; i++ {
		data = append(data, rand.Intn(530))
	}

	fmt.Println(data)
	tmp := data
	fmt.Println("---------------")
	BucketSort(data)

	fmt.Println(data)
	sort.Ints(tmp)
	fmt.Println(tmp)

	data1 := []int{5, 1, 3}
	BucketSort(data1)
	t.Log("data1 ---- ", data1)

	data2 := []int{0, 0, 1, 0, 3, -5, 0, 7}
	BucketSort(data2)
	t.Log("data2 ---- ", data2)
}

你可能感兴趣的文章

bubbleSort

bubbleSort_test

bucket_sort

0  赞