sort

package
v0.0.0-...-10bc058 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BubbleSort

func BubbleSort(nums []int)

从右向左,依次比较,如果顺序相反就交换,一轮就可以把最小 or 最大的冒泡到左端

func HeapSort

func HeapSort(values []int)

func InsertSort

func InsertSort(nums []int)

有点像打牌,从左到右依次排好序,右边挑出一个依次跟左边的数进行比较,插到合适的位置,左边都是已经排好的

func MergeSort

func MergeSort(args []int) []int

归并排序,就是二分,分到最后,然后 merge

func QuickSort

func QuickSort(nums []int)

快排的基本思想,选取一个基准值,将比基准值大的放在左边,比基准值小的放在右边,然后递归 具体的做法:每次随机选择基准值,比如选最右边那个,然后左索引选最左,右索引选择右起第二个 左边向右移,右边向左移,遇到左边比基准值大,左边停止移动,右边比基准值小,右边停止移动,左右都停止时,交换左右 左右相遇时停止移动,这个时候如果左比基准值大,交换 注意是否交换基准值,决定了子问题的规模

func SelectSort

func SelectSort(nums []int)

Types

This section is empty.

Jump to

Keyboard shortcuts

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