Skip to content

Commit 2efdead

Browse files
author
polun
committed
add selection sort
1 parent 5891f24 commit 2efdead

12 files changed

+37
-3
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

code/bubbleSort.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
const util = require('./util.js');
2+
13
function bubbleSort(arr) {
24
const length = arr.length;
5+
36
for (let i = 0; i < length - 1; i++) {
47
for (let j = 0; j < length - i - 1; j++) {
58
if (arr[j] > arr[j + 1]) {
@@ -11,6 +14,4 @@ function bubbleSort(arr) {
1114
}
1215
}
1316

14-
const arr = [12, 3, 10, 11, 1];
15-
bubbleSort(arr);
16-
console.log(arr);
17+
util(bubbleSort);

0 commit comments

Comments
 (0)