Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b1ad456
Remove QuickSelect doctest
defaude Oct 5, 2021
4b1799e
Remove AverageMedian doctest
defaude Oct 5, 2021
852e16f
Migrate doctest for BinaryExponentiationRecursive.js
defaude Oct 5, 2021
25c29b6
Migrate doctest for EulersTotient.js
defaude Oct 5, 2021
7b8ec07
Migrate doctest for PrimeFactors.js
defaude Oct 5, 2021
e7836e4
Migrate doctest for BogoSort.js
defaude Oct 5, 2021
402ab5c
Migrate doctest for BeadSort.js
defaude Oct 5, 2021
3eff8fd
Migrate doctest for BucketSort.js
defaude Oct 5, 2021
9627cfb
Migrate doctest for CocktailShakerSort.js
defaude Oct 5, 2021
e0e3c19
Migrate doctest for MergeSort.js
defaude Oct 5, 2021
942f9fb
Migrate doctest for QuickSort.js
defaude Oct 5, 2021
3d48cbf
Migrate doctest for ReverseString.js
defaude Oct 5, 2021
dd619c9
Migrate doctest for ReverseString.js
defaude Oct 5, 2021
6b820f3
Migrate doctest for ValidateEmail.js
defaude Oct 5, 2021
db7f626
Migrate doctest for ConwaysGameOfLife.js
defaude Oct 5, 2021
f2aa40c
Remove TernarySearch doctest
defaude Oct 5, 2021
7f5d7fe
Migrate doctest for BubbleSort.js
defaude Oct 5, 2021
c3747e9
Remove doctest from CI and from dependencies
defaude Oct 5, 2021
8274f40
Migrate doctest for RgbHsvConversion.js
defaude Oct 6, 2021
a383356
Add --fix option to "standard" npm script
defaude Oct 6, 2021
bbeeefb
Migrate doctest for BreadthFirstSearch.js
defaude Oct 6, 2021
1244f3c
Migrate doctest for BreadthFirstShortestPath.js
defaude Oct 6, 2021
d019e85
Migrate doctest for EulerMethod.js
defaude Oct 6, 2021
bf68fdd
Migrate doctest for Mandelbrot.js
defaude Oct 6, 2021
cbece80
Migrate doctest for FloodFill.js
defaude Oct 6, 2021
59796a2
Migrate doctest for KochSnowflake.js
defaude Oct 6, 2021
a8ad3a3
Update npm lockfile
defaude Oct 6, 2021
78f5dc4
Update README and COMMITTING with a few bits & bobs regarding testing…
defaude Oct 6, 2021
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Migrate doctest for BucketSort.js
(also remove inline test driver code)
  • Loading branch information
defaude committed Oct 6, 2021
commit 3eff8fd9a70132cd1e0e31f2686ad010542d3d9d
32 changes: 14 additions & 18 deletions Sorts/BucketSort.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
/*
[Wikipedia says](https://en.wikipedia.org/wiki/Bucket_sort#:~:text=Bucket%20sort%2C%20or%20bin%20sort,applying%20the%20bucket%20sorting%20algorithm.&text=Sort%20each%20non%2Dempty%20bucket.): Bucket sort, or bin sort, is a sorting algorithm that works by distributing the
elements of an array into a number of buckets. Each bucket is then sorted individually, either using
a different sorting algorithm, or by recursively applying the bucket sorting algorithm. It is a
distribution sort, and is a cousin of radix sort in the most to least significant digit flavour.
Bucket sort is a generalization of pigeonhole sort. Bucket sort can be implemented with comparisons
and therefore can also be considered a comparison sort algorithm. The computational complexity estimates
involve the number of buckets.

Time Complexity of Solution:
Best Case O(n); Average Case O(n); Worst Case O(n)

*/

/**
* bucketSort returns an array of numbers sorted in increasing order.
* BucketSort implementation.
*
* Wikipedia says: Bucket sort, or bin sort, is a sorting algorithm that works by distributing the elements of an array
* into a number of buckets. Each bucket is then sorted individually, either using a different sorting algorithm, or by
* recursively applying the bucket sorting algorithm. It is a distribution sort, and is a cousin of radix sort in the
* most to least significant digit flavour. Bucket sort is a generalization of pigeonhole sort. Bucket sort can be
* implemented with comparisons and therefore can also be considered a comparison sort algorithm. The computational
* complexity estimates involve the number of buckets.
*
* @see https://en.wikipedia.org/wiki/Bucket_sort#:~:text=Bucket%20sort%2C%20or%20bin%20sort,applying%20the%20bucket%20sorting%20algorithm.&text=Sort%20each%20non%2Dempty%20bucket.
*
* Time Complexity of Solution:
* Best Case O(n); Average Case O(n); Worst Case O(n)
*
* @param {number[]} list The array of numbers to be sorted.
* @param {number} size The size of the buckets used. If not provided, size will be 5.
* @return {number[]} An array of numbers sorted in increasing order.
*/
function bucketSort (list, size) {
export function bucketSort (list, size) {
if (undefined === size) {
size = 5
}
Expand Down Expand Up @@ -60,5 +58,3 @@ function bucketSort (list, size) {
}
return sorted
}

export { bucketSort }