diff --git a/Sorts/PigeonHoleSort.js b/Sorts/PigeonHoleSort.js index 333027c68c..30c1bcb813 100644 --- a/Sorts/PigeonHoleSort.js +++ b/Sorts/PigeonHoleSort.js @@ -29,4 +29,5 @@ export function pigeonHoleSort (arr) { arr[index++] = j + min } } + return arr } diff --git a/Sorts/test/pigeonHoleSort.test.js b/Sorts/test/pigeonHoleSort.test.js new file mode 100644 index 0000000000..6816051c3b --- /dev/null +++ b/Sorts/test/pigeonHoleSort.test.js @@ -0,0 +1,19 @@ +import { pigeonHoleSort } from '../PigeonHoleSort' + +test('The pigeonHoleSort of the array [1, 4, 3, 2] is [1, 2, 3, 4]', () => { + const arr = [1, 4, 3, 2] + const res = pigeonHoleSort(arr) + expect(res).toEqual([1, 2, 3, 4]) +}) + +test('The pigeonHoleSort of the array [5, 4, 1, 2] is [1, 2, 4, 5]', () => { + const arr = [5, 4, 1, 2] + const res = pigeonHoleSort(arr) + expect(res).toEqual([1, 2, 4, 5]) +}) + +test('The pigeonHoleSort of the array [18, 31, 29, 35, 11] is [11, 18, 29, 31, 35]', () => { + const arr = [18, 31, 29, 35, 11] + const res = pigeonHoleSort(arr) + expect(res).toEqual([11, 18, 29, 31, 35]) +})
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: