gsort

package
v0.0.0-...-a046bda Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sort

func Sort(sli []int) []int

鸡尾酒排序 排序过程就像钟摆一样,第1轮从左到右,第 2 轮从右到左,第 3 轮再从左到右…… 目的就是解决像无序数列 {2,3,4,5,6,7,8,1}这样,只有少数元素位置不对的情况 实现类似冒泡算法: 若判断出数列已经有序,并做出标记,那么剩下的几轮排序就不必执行了,可以提前结束工作。 每一轮排序后,记录下来最后一次元素交换的位置,该位置即为无序数列的边界, 再往后就是有序区了。有序区则没有必要继续往下执行了

Types

This section is empty.

Jump to

Keyboard shortcuts

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