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

Skip to content

Commit f79e88f

Browse files
author
AndreyGeonya
committed
lsd and msd jsdoc
1 parent 29051fa commit f79e88f

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

src/sorting/lsd.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22
'use strict';
33

44
/**
5-
* Sorts strings lexicographically.
6-
* Complexity O(n*m)
5+
* Sorts strings lexicographically.<br><br>
6+
* Time complexity: O(N*M) for N keys which have M or fewer digits.
7+
*
8+
* @example
9+
*
10+
* var sort = require('../src/sorting/lsd').lsd;
11+
* // [ 'aab', 'aaa', 'acc', 'bbb', 'bcc' ]
12+
* console.log(sort(['aab', 'bbb', 'aaa', 'acc', 'bcc']));
713
*
814
* @public
9-
* @param {Array} arr Input array
10-
* @param {Number} letterIdx Index to start sorting from
11-
* @returns {Array} Sorted array
15+
* @module sorting/lsd
16+
* @param {Array} arr Array which should be sorted.
17+
* @param {Number} letterIdx Optional. Index to start sorting from.
18+
* @return {Array} Sorted array.
1219
*/
1320
function lsd(arr, letterIdx) {
1421
var temp;

src/sorting/msd.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,22 @@
3737

3838
/**
3939
* Sorts given array lexicographically.
40-
* The algorithms knows how to treat
41-
* differently length strings.
42-
* The algorithm is stable.
40+
* Algorithms knows how to treat
41+
* differently length strings.<br><br>
42+
* Algorithm is stable.
43+
* Time complexity: O(N*M) for N keys which have M or fewer digits.
4344
*
44-
* Complexity O(n*m)
45+
* @example
46+
*
47+
* var sort = require('../src/sorting/msd').msd;
48+
* // [ 'aab', 'aaa', 'acc', 'bbb', 'bcc' ]
49+
* console.log(sort(['aab', 'bbb', 'aaa', 'acc', 'bcc']));
4550
*
4651
* @public
47-
* @param {Array} arr The array, which needs to be sorted
48-
* @param {Number} d The digit from which the sorting should start
49-
* @return {Array} The sorted array
52+
* @module sorting/msd
53+
* @param {Array} arr Array which should be sorted.
54+
* @param {Number} d Digit from which sorting should start.
55+
* @return {Array} Sorted array.
5056
*/
5157

5258
function msd(arr, d) {

0 commit comments

Comments
 (0)