Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef68c0a

Browse files
author
AndreyGeonya
committed
add insertion-binary-sort jsdoc
1 parent 0d143db commit ef68c0a

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/sorting/insertion-binary-sort.js

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

88
/**
9-
* Modified version of insertionsort. It uses binary search for finding
9+
* Modified version of insertion sort. It uses binary search for finding
1010
* where the current element should be inserted. It's correct because
1111
* the binary search looks just in the first part of the array
12-
* which is actually sorted. It's complexity is O(n^2)
12+
* which is actually sorted.<br><br>
13+
* Time complexity: O(N^2).
14+
*
15+
* @example
16+
*
17+
* var sort = require('path-to-algorithms/src' +
18+
* '/sorting/insertion-binary-sort').insertionBinarySort;
19+
* console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ]
1320
*
1421
* @public
15-
* @param {array} array Input array
16-
* @param {array} array Sorted array
22+
* @module sorting/insertion-binary-sort
23+
* @param {Array} array Input array.
24+
* @param {Function} cmp Optional. A function that defines an
25+
* alternative sort order. The function should return a negative,
26+
* zero, or positive value, depending on the arguments.
27+
* @return {Array} Sorted array.
1728
*/
1829
function insertionBinarySort(array, cmp) {
1930
cmp = cmp || comparator;

0 commit comments

Comments
 (0)