Skip to content

Commit 9d2da8f

Browse files
committedOct 12, 2019
add complexity
1 parent e0e1846 commit 9d2da8f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎src/_Searching_/JumpSearch/index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
/**
2+
* Note: Array must be sorted for jump search
3+
* Complexity:
4+
* Worst case time complexity: O(√N)
5+
* Average case time complexity: O(√N)
6+
* Best case time complexity: O(1)
7+
* Space complexity: O(1)
8+
*/
19
function jumpSearch(arr, key) {
2-
// treat jumps larger than array size as linear search
310
const n = arr.length;
411
const jump = Math.floor(Math.sqrt(n));
512
let step = jump;

0 commit comments

Comments
 (0)