2020-10-21
插入排序
输入:n个数的一个序列<a1,a2,a3,…,an>
输出:输出一个排列<b1,b2,b3,…,bn>满足b1<=b1<=b2…<=bn
INSERTION-SORT(A)
for j =2 to A.length
key = A[j]
//insert A[j] to the sorted seq A[1..j-1]
i = j -1
while i >0 and A[i] > key
A[i+1] = A[i]
i =
原创
2020-10-21 23:34:23 ·
74 阅读 ·
0 评论