Skip to content

Commit 6f33f99

Browse files
authored
merge: Add test case and fix pigeonHoleSort Algorithm (TheAlgorithms#967)
1 parent 871a49f commit 6f33f99

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Sorts/PigeonHoleSort.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ export function pigeonHoleSort (arr) {
2929
arr[index++] = j + min
3030
}
3131
}
32+
return arr
3233
}

Sorts/test/pigeonHoleSort.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { pigeonHoleSort } from '../PigeonHoleSort'
2+
3+
test('The pigeonHoleSort of the array [1, 4, 3, 2] is [1, 2, 3, 4]', () => {
4+
const arr = [1, 4, 3, 2]
5+
const res = pigeonHoleSort(arr)
6+
expect(res).toEqual([1, 2, 3, 4])
7+
})
8+
9+
test('The pigeonHoleSort of the array [5, 4, 1, 2] is [1, 2, 4, 5]', () => {
10+
const arr = [5, 4, 1, 2]
11+
const res = pigeonHoleSort(arr)
12+
expect(res).toEqual([1, 2, 4, 5])
13+
})
14+
15+
test('The pigeonHoleSort of the array [18, 31, 29, 35, 11] is [11, 18, 29, 31, 35]', () => {
16+
const arr = [18, 31, 29, 35, 11]
17+
const res = pigeonHoleSort(arr)
18+
expect(res).toEqual([11, 18, 29, 31, 35])
19+
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy