Skip to content

Commit a5d1ccf

Browse files
committed
添加插入排序的逻辑
1 parent 10c4cca commit a5d1ccf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sort/src/main/java/com/mistray/insertion/Insertion.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* @author MistRay
77
* @create 2018-11-16
88
* @desc 插入排序
9+
* 逻辑:
10+
* 相当于将一个无序数组,拆成两个数组,其中一个有序另一个无序,数组a元素数量开始为1,数组b元素数量为n-1
11+
* 然后将数组b的元素依次有序添加到数组a中,最后数组b的元素会为0,数组a的元素数为n,最后数组a会完全有序
912
* 时间复杂度:
1013
* 平均情况:O(n^2)
1114
* 最好情况:O(n)

0 commit comments

Comments
 (0)