Skip to content

Commit 115fde4

Browse files
author
AndreyGeonya
committed
add quicksort-middle jsdoc
1 parent 0728085 commit 115fde4

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/sorting/mergesort.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676

7777
/**
7878
* Merge sort algorithm.<br><br>
79-
* Time complexity: O(N logN).
79+
* Time complexity: O(N log(N)).
8080
*
8181
* @example
8282
*

src/sorting/quicksort-middle.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/**
2-
* Quicksort algorithm. It's with complexity O(n log(n)).
3-
* In this version of quicksort I use the middle element of the
4-
* array for pivot.
5-
*/
6-
71
(function (exports) {
82

93
'use strict';
@@ -72,8 +66,23 @@
7266
}
7367

7468
/**
75-
* Quicksort's initial point
69+
* Quicksort algorithm. In this version of quicksort used
70+
* middle element of array for the pivot.<br><br>
71+
* Time complexity: O(N log(N)).
72+
*
73+
* @example
74+
*
75+
* var sort = require('path-to-algorithms/src' +
76+
* '/sorting/quicksort-middle').quickSort;
77+
* console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ]
78+
*
7679
* @public
80+
* @module sorting/mergesort
81+
* @param {Array} array Input array.
82+
* @param {Function} cmp Optional. A function that defines an
83+
* alternative sort order. The function should return a negative,
84+
* zero, or positive value, depending on the arguments.
85+
* @return {Array} Sorted array.
7786
*/
7887
return function (array, cmp) {
7988
cmp = cmp || compare;
@@ -85,4 +94,4 @@
8594

8695
exports.quickSort = quickSort;
8796

88-
}(typeof exports === 'undefined' ? window : exports));
97+
})(typeof window === 'undefined' ? module.exports : window);

0 commit comments

Comments
 (0)