Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9d2da8f

Browse files
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‎

Lines changed: 8 additions & 1 deletion
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)

AltStyle によって変換されたページ (->オリジナル) /