Skip to content

Commit c4c0078

Browse files
committed
Fix code style issues
1 parent 8a4e8c4 commit c4c0078

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

Sorts/QuickSort.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
*/
1111
function quickSort(items, left = 0, right = items.length - 1) {
1212
if (left < right) {
13-
let pivotIndex = partition(items, left, right);
13+
let pivotIndex = partition(items, left, right)
1414

15-
quickSort(items, left, pivotIndex - 1);
16-
quickSort(items, pivotIndex + 1, right);
15+
quickSort(items, left, pivotIndex - 1)
16+
quickSort(items, pivotIndex + 1, right)
1717
}
18-
return items;
18+
return items
1919
}
2020

2121
/**
@@ -29,18 +29,18 @@ function quickSort(items, left = 0, right = items.length - 1) {
2929
* @return {number} - The index of the pivot element after partitioning.
3030
*/
3131
function partition(items, left, right) {
32-
const pivot = items[right];
33-
let i = left - 1;
32+
const pivot = items[right]
33+
let i = left - 1
3434

3535
for (let j = left; j < right; j++) {
3636
if (items[j] <= pivot) {
37-
i++;
38-
[items[i], items[j]] = [items[j], items[i]];
37+
i++
38+
;[items[i], items[j]] = [items[j], items[i]]
3939
}
4040
}
4141

42-
[items[i + 1], items[right]] = [items[right], items[i + 1]];
43-
return i + 1;
42+
;[items[i + 1], items[right]] = [items[right], items[i + 1]]
43+
return i + 1
4444
}
4545

46-
export { quickSort };
46+
export { quickSort }

Sorts/QuickSortRecursive.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
*/
1212
function quickSort(items, left = 0, right = items.length - 1) {
1313
if (!Array.isArray(items)) {
14-
throw new Error('Please input a valid list or array.');
14+
throw new Error('Please input a valid list or array.')
1515
}
1616

1717
if (left < right) {
18-
let pivotIndex = partition(items, left, right);
19-
quickSort(items, left, pivotIndex - 1);
20-
quickSort(items, pivotIndex + 1, right);
18+
let pivotIndex = partition(items, left, right)
19+
quickSort(items, left, pivotIndex - 1)
20+
quickSort(items, pivotIndex + 1, right)
2121
}
2222

23-
return items;
23+
return items
2424
}
2525

2626
/**
@@ -34,18 +34,18 @@ function quickSort(items, left = 0, right = items.length - 1) {
3434
* @return {number} - The index of the pivot element after partitioning.
3535
*/
3636
function partition(items, left, right) {
37-
const pivot = items[right];
38-
let i = left - 1;
37+
const pivot = items[right]
38+
let i = left - 1
3939

4040
for (let j = left; j < right; j++) {
4141
if (items[j] <= pivot) {
42-
i++;
43-
[items[i], items[j]] = [items[j], items[i]];
42+
i++
43+
;[items[i], items[j]] = [items[j], items[i]]
4444
}
4545
}
4646

47-
[items[i + 1], items[right]] = [items[right], items[i + 1]];
48-
return i + 1;
47+
;[items[i + 1], items[right]] = [items[right], items[i + 1]]
48+
return i + 1
4949
}
5050

51-
export { quickSort };
51+
export { quickSort }

0 commit comments

Comments
 (0)