Skip to content

Commit 369aaaf

Browse files
committed
add
1 parent b79b97e commit 369aaaf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

3.insertionSort.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,15 @@ def insertionSort(arr):
5353
## 5. Go 代码实现
5454
```go
5555
func insertionSort(arr []int) []int {
56-
for i := range arr {
56+
for i, _ := range arr {
57+
//前面那个数位。
5758
preIndex := i - 1
59+
// 正在遍历的那个数位。
5860
current := arr[i]
61+
// 假如说 前面的那个数位大于等于0并且,
62+
// 前面的那个数值是大于正在遍历的那个数值的
5963
for preIndex >= 0 && arr[preIndex] > current {
64+
// 正在正在遍历的那个次数就和它前面的那个交换顺序。并且preindex要减去1
6065
arr[preIndex+1] = arr[preIndex]
6166
preIndex -= 1
6267
}

0 commit comments

Comments
 (0)