- 1
- 0
- 约1.58万字
- 约 87页
- 2017-07-08 发布于贵州
- 举报
算法分析初学了
An Example: Insertion Sort InsertionSort(A, n) {for i = 2 to n { key = A[i] j = i - 1; while (j 0) and (A[j] key) { A[j+1] = A[j] j = j - 1 } A[j+1] = key} } 10 30 40 20 1 2 3 4 i = 4 j = 3 key = 20A[j] = 40 A[j+1] = 20 An Example: Insertion Sort InsertionSort(A, n) {for i = 2 to n { key = A[i] j = i - 1; while (j 0) and (A[j] key) { A[j+1] = A[j] j = j - 1 } A[j+1] = key} } 10 30 40 20 1 2 3 4 i = 4 j = 3 key = 20A[j] = 40 A[j+1] = 20 An Example: Insertion Sort InsertionSort(A, n) {for i = 2 to n { key = A[i] j = i - 1; while (j 0) and (A[j] key) {
原创力文档

文档评论(0)