Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ea66d5e

Browse files
Merge pull request #206 from zdsppl/fix-insertion-sort
bugfix: fix the mistakes in the description of insertion sort.
2 parents 0cc0e17 + 58c6ab9 commit ea66d5e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎Contents/01.Array/02.Array-Sort/03.Array-Insertion-Sort.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
1. 初始状态下,有序区间为 $[0, 0],ドル无序区间为 $[1, n - 1]$。
1515
2. 第 1ドル$ 趟插入:
1616
1. 取出无序区间 $[1, n - 1]$ 中的第 1ドル$ 个元素,即 $nums[1]$。
17-
2. 从右到左遍历有序区间中的元素,将比 $nums[1]$ 小的元素向后移动 1ドル$ 位。
18-
3. 如果遇到大于或等于 $nums[1]$ 的元素时,说明找到了插入位置,将 $nums[1]$ 插入到该位置。
17+
2. 从右到左遍历有序区间中的元素,将比 $nums[1]$ 大的元素向后移动 1ドル$ 位。
18+
3. 如果遇到小于或等于 $nums[1]$ 的元素时,说明找到了插入位置,将 $nums[1]$ 插入到该位置。
1919
4. 插入元素后有序区间变为 $[0, 1],ドル无序区间变为 $[2, n - 1]$。
2020
3. 第 2ドル$ 趟插入:
2121
1. 取出无序区间 $[2, n - 1]$ 中的第 1ドル$ 个元素,即 $nums[2]$。
22-
2. 从右到左遍历有序区间中的元素,将比 $nums[2]$ 小的元素向后移动 1ドル$ 位。
23-
3. 如果遇到大于或等于 $nums[2]$ 的元素时,说明找到了插入位置,将 $nums[2]$ 插入到该位置。
22+
2. 从右到左遍历有序区间中的元素,将比 $nums[2]$ 大的元素向后移动 1ドル$ 位。
23+
3. 如果遇到小于或等于 $nums[2]$ 的元素时,说明找到了插入位置,将 $nums[2]$ 插入到该位置。
2424
4. 插入元素后有序区间变为 $[0, 2],ドル无序区间变为 $[3, n - 1]$。
2525
4. 依次类推,对剩余无序区间中的元素重复上述插入过程,直到所有元素都插入到有序区间中,排序结束。
2626

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /