Skip to content

Commit 15c2096

Browse files
Ankush263github-actions
and
github-actions
authored
merge: Add test case to jump search Algorithm (TheAlgorithms#1041)
* Add test case to jump search Algorithm * Updated Documentation in README.md * Remove commented code Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
1 parent 398b682 commit 15c2096

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

Data-Structures/Linked-List/SinglyLinkedList.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class LinkedList {
7777
this.headNode = this.headNode.next
7878
this.length--
7979
}
80-
console.log(removedNode.data)
8180
return removedNode?.data
8281
}
8382

Search/JumpSearch.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,5 @@ const jumpSearch = (arr, value) => {
2929
}
3030
return -1
3131
}
32-
const arr = [0, 0, 4, 7, 10, 23, 34, 40, 55, 68, 77, 90]
33-
jumpSearch(arr, 4)
34-
jumpSearch(arr, 34)
35-
jumpSearch(arr, 77)
32+
33+
export { jumpSearch }

Search/test/jumpSearch.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { jumpSearch } from '../JumpSearch'
2+
3+
test('jumpSearch([0, 0, 4, 7, 10, 23, 34, 40, 55, 68, 77, 90], 77) => 10', () => {
4+
const arr = [0, 0, 4, 7, 10, 23, 34, 40, 55, 68, 77, 90]
5+
const res = jumpSearch(arr, 77)
6+
expect(res).toEqual(10)
7+
})
8+
9+
test('jumpSearch([11, 12, 15, 65, 78, 90], 4) => -1', () => {
10+
const arr = [11, 12, 15, 65, 78, 90]
11+
const res = jumpSearch(arr, 4)
12+
expect(res).toEqual(-1)
13+
})
14+
15+
test('jumpSearch([11, 12, 15, 65, 78, 90], 11) => 0', () => {
16+
const arr = [11, 12, 15, 65, 78, 90]
17+
const res = jumpSearch(arr, 11)
18+
expect(res).toEqual(0)
19+
})

0 commit comments

Comments
 (0)