sort

package
v0.0.0-...-66c0c6b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BubbleSort

func BubbleSort(arr []int)

func BubbleSortAcc

func BubbleSortAcc(arr []int)

func BucketSort

func BucketSort(arr []int)

func CopyArr

func CopyArr(originArr []int, maxSize int) []int

func CountingSort

func CountingSort(arr []int)

CountingSort It sorts the elements of an array by counting the number of occurrences of each unique element in the array. The count is stored in an auxiliary array and the sorting si done by mapping the count as an index of the auxiliary array.

1.Find out the maximum element (let ie be maxElement) from the given array. 2.Initialize an array of length as maxElement value + 1 with all elements 0. This array is used for storing the count of the elements in the array. 3.Store the count of each element at their respective index in count array 4.Store cumulative sum of the elements of the count array. It helps in placing the elements into the correct index of the sorted array. 5.Find the index of each element of the original array in the count array. This gives the cumulative count. Place the element at the index calculated. 6.After placing each element at its correct position, decrease its count by one.

func DataComparator

func DataComparator(sf sortFunc, benchmarkNum int, maxArrSize int, maxNum int, isAsc bool)

func GenerateRandomArr

func GenerateRandomArr(maxSize int, maxNum int) []int

func HeapSort

func HeapSort(arr []int)

总是从第一层非叶子节点开始遍历

func InsertSort

func InsertSort(arr []int)

func InsertSortSimplify

func InsertSortSimplify(arr []int)

func IsEquals

func IsEquals(standardArr []int, customizedArr []int) bool

func MergeSort

func MergeSort(arr []int)

func PrintArr

func PrintArr(arr []int)

func QuickSort

func QuickSort(arr []int)

func QuickSort2

func QuickSort2(arr []int)

func RadixSort

func RadixSort(arr []int)

func SelectSort

func SelectSort(arr []int)

func ShellSort

func ShellSort(arr []int)

ShellSort 从 internal 不断地往 index 0 进行交换才能确保所有元素的有序性 如果是从 index 0 不断往后遍历会出现部分元素无序现象

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL