We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e0e1846 commit 9d2da8fCopy full SHA for 9d2da8f
src/_Searching_/JumpSearch/index.js
@@ -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
+*/
9
function jumpSearch(arr, key) {
- // treat jumps larger than array size as linear search
10
const n = arr.length;
11
const jump = Math.floor(Math.sqrt(n));
12
let step = jump;
0 commit comments