package
Version:
v0.0.0-...-a046bda
Opens a new window with list of versions in this module.
Published: Aug 25, 2021
License: MIT
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
鸡尾酒排序
排序过程就像钟摆一样,第1轮从左到右,第 2 轮从右到左,第 3 轮再从左到右……
目的就是解决像无序数列 {2,3,4,5,6,7,8,1}这样,只有少数元素位置不对的情况
实现类似冒泡算法:
若判断出数列已经有序,并做出标记,那么剩下的几轮排序就不必执行了,可以提前结束工作。
每一轮排序后,记录下来最后一次元素交换的位置,该位置即为无序数列的边界,
再往后就是有序区了。有序区则没有必要继续往下执行了
Source Files
¶
Click to show internal directories.
Click to hide internal directories.