标签:
插入排序方法和从扑克牌堆里面拿牌还挺像的,只不过现在要抽象出那个过程,然后用伪代码实现
在知晓了算法的过程之后再来写伪代码是不是更方便呢
下面是插入排序一个数组的计算过程
插入排序的伪代码:
1 INSERTION-SORT(A) 2 for j = 2 to A.length 3 key = A[j] 4 // Insert A[j] into the sorted sequence A[1..j-1] 5 i = j - 1 6 while i>0 and A[i]>key 7 A[i+1] = A[i] 8 i = i-1 9 A[i+1] = key
标签:
原文地址:http://www.cnblogs.com/tuhooo/p/5597474.html