File tree Expand file tree Collapse file tree 2 files changed +42
-7
lines changed Expand file tree Collapse file tree 2 files changed +42
-7
lines changed Original file line number Diff line number Diff line change 1313
1414#### 选择排序
1515
16- ``` java
17-
16+ ``` tsx
17+ const selectSort = function (nums : number []) {
18+ const len = nums .length
19+ for (let i = 0 ; i < len ; i ++ ) {
20+ let min = i
21+ for (let j = i + 1 ; j < len ; j ++ ) {
22+ if (nums [j ] < nums [min ]) {
23+ min = j
24+ }
25+ }
26+ ;[nums [i ], nums [min ]] = [nums [min ], nums [i ]]
27+ }
28+ return nums
29+ }
1830```
1931
2032#### 冒泡排序
2133
22- ``` java
23-
34+ ``` tsx
35+ const bubbleSort = function (arrs : number []) {
36+ const len = arrs .length
37+ let isSortFlag = false // 如果排好序只需遍历一遍
38+ for (let i = len - 1 ; i > 0 && ! isSortFlag ; i -- ) {
39+ isSortFlag = true
40+ for (let j = 0 ; j < i ; j ++ ) {
41+ if (arrs [j ] > arrs [j + 1 ]) {
42+ isSortFlag = false
43+ ;[arrs [j ], arrs [j + 1 ]] = [arrs [j + 1 ], arrs [j ]]
44+ }
45+ }
46+ }
47+ return arrs
48+ }
2449```
2550
2651#### 插入排序
2752
28- ``` java
29-
53+ ``` tsx
54+ const insertSort = function (nums : number []) {
55+ const len = nums .length
56+ for (let i = 1 ; i < len ; i ++ ) {
57+ for (let j = i ; j > 0 ; j -- ) {
58+ if (nums [j ] < nums [j - 1 ]) {
59+ ;[nums [j ], nums [j - 1 ]] = [nums [j - 1 ], nums [j ]]
60+ }
61+ }
62+ }
63+ return nums
64+ }
3065```
3166
3267#### 希尔排序
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ FaaS平台最具吸引力的是资源弹性,允许用户程序在几秒内按
1616
17172.1 工作流
1818
19- ![ ] ( /Users/didi/Desktop/leetcode/论文 /image/workflows.png)
19+ ![ ] ( . /image/workflows.png)
2020
21212.2 工作负载分析
2222
You can’t perform that action at this time.
0 commit comments