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

双插入排序 每次从左边取两个数字,大的数字记录为 big,小的数字记为 small,然后不断向前寻找 big 的插入位置, 当 big 插入后,small 直接从 big 的插入位置开始,向前寻找自己的插入位置。 最后一个数字可能需要单独插入。 note: 这里实现非哨兵的方式 具体原理可以参考:https://leetcode-cn.com/leetbook/read/sort-algorithms/phzr8m/ 根据java sort里的实现, 当数据量小于47个时,采用插入排序的时间复杂度应该是最优的

Types

This section is empty.

Jump to

Keyboard shortcuts

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