Skip to content

Commit 35c0cdb

Browse files
author
AndreyGeonya
committed
add recurisve insertionsort jsdoc
1 parent 2830903 commit 35c0cdb

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/sorting/recursive-insertionsort.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,25 @@
66
}
77

88
/**
9-
* Recursive version of insertionsort. Complexity O(n^2).
9+
* Recursive version of insertion sort.<br><br>
10+
* Time complexity: O(N^2).
11+
*
12+
* @example
13+
*
14+
* var sort = require('path-to-algorithms/src/sorting/'+
15+
* 'recursive-insertionsort').recursiveInsertionSort;
16+
* console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ]
1017
*
1118
* @public
12-
* @param {array} array Input array
13-
* @param {number} [max] Index of the element which place we should find
14-
* in the current function call
15-
*/
19+
* @module sorting/recursive-insertionsort
20+
* @param {Array} array Input array.
21+
* @param {Function} cmp Optional. A function that defines an
22+
* alternative sort order. The function should return a negative,
23+
* zero, or positive value, depending on the arguments.
24+
* @param {Number} max Optional. Index of the element which place
25+
* we should find in the current function call.
26+
* @return {Array} Sorted array.
27+
*/
1628
function recursiveInsertionSort(array, cmp, max) {
1729
cmp = cmp || compare;
1830
if (max <= 0) {
@@ -32,4 +44,4 @@
3244

3345
exports.recursiveInsertionSort = recursiveInsertionSort;
3446

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

0 commit comments

Comments
 (0)