Skip to content

Commit 5438db2

Browse files
author
Praveen Agrawal
committed
Improve jump search documentation and complexity explanation
1 parent 678dedb commit 5438db2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

searches/jump_search.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
"""
2-
Pure Python implementation of the jump search algorithm.
3-
This algorithm iterates through a sorted collection with a step of n^(1/2),
4-
until the element compared is bigger than the one searched.
5-
It will then perform a linear search until it matches the wanted number.
6-
If not found, it returns -1.
2+
Jump Search Algorithm
73
8-
https://en.wikipedia.org/wiki/Jump_search
4+
Jump Search works on sorted arrays by jumping ahead by fixed steps
5+
instead of checking every element sequentially.
6+
7+
Time Complexity:
8+
Best case: O(1)
9+
Average case: O(√n)
10+
Worst case: O(√n)
11+
12+
Space Complexity:
13+
O(1)
914
"""
1015

1116
import math

0 commit comments

Comments
 (0)