Skip to content

Commit 2805075

Browse files
committed
Rework started
1 parent e5d1296 commit 2805075

File tree

19 files changed

+154
-100256
lines changed

19 files changed

+154
-100256
lines changed

Algorithms/BubbleSort.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class BubbleSort extends SortingAlgorithm {
2+
3+
i = 0;
4+
5+
constructor(values) {
6+
super(values);
7+
}
8+
9+
step() {
10+
if (this.i < values.length) {
11+
for (let j = 0; j < values.length - this.i - 1; j++) {
12+
let a = values[j];
13+
let b = values[j + 1];
14+
if (a > b) {
15+
super.incComparisons();
16+
super.swap(values, j, j + 1);
17+
}
18+
}
19+
} else {
20+
noLoop();
21+
}
22+
this.i++;
23+
}
24+
}

Algorithms/SortingAlgorithm.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class SortingAlgorithm {
2+
3+
comparisons = 0;
4+
values;
5+
6+
constructor(values) {
7+
this.values = values;
8+
loop();
9+
}
10+
11+
incComparisons() {
12+
this.comparisons++;
13+
}
14+
15+
swap(arr, a, b) {
16+
let temp = arr[a];
17+
arr[a] = arr[b];
18+
arr[b] = temp;
19+
}
20+
21+
}

BogoSort/sketch.js

-61
This file was deleted.

BubbleSort/index.html

-15
This file was deleted.

BubbleSort/sketch.js

-62
This file was deleted.

CocktailSort/index.html

-15
This file was deleted.

CocktailSort/sketch.js

-67
This file was deleted.

InsertionSort/index.html

-15
This file was deleted.

InsertionSort/sketch.js

-55
This file was deleted.

QuickSort/index.html

-15
This file was deleted.

0 commit comments

Comments
 (0)