File tree 2 files changed +42
-7
lines changed
2 files changed +42
-7
lines changed Original file line number Diff line number Diff line change 13
13
14
14
#### 选择排序
15
15
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
+ }
18
30
```
19
31
20
32
#### 冒泡排序
21
33
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
+ }
24
49
```
25
50
26
51
#### 插入排序
27
52
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
+ }
30
65
```
31
66
32
67
#### 希尔排序
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ FaaS平台最具吸引力的是资源弹性,允许用户程序在几秒内按
16
16
17
17
2.1 工作流
18
18
19
- ![ ] ( /Users/didi/Desktop/leetcode/论文 /image/workflows.png)
19
+ ![ ] ( . /image/workflows.png)
20
20
21
21
2.2 工作负载分析
22
22
You can’t perform that action at this time.
0 commit comments